| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
import config |
|---|
| 13 |
import shutil |
|---|
| 14 |
|
|---|
| 15 |
import dbus |
|---|
| 16 |
from plugins.events import EventPlugin |
|---|
| 17 |
awn = '' |
|---|
| 18 |
out = "/tmp/current.cover" |
|---|
| 19 |
class PictureSaver(EventPlugin): |
|---|
| 20 |
PLUGIN_ID = "AWN Album Art Display" |
|---|
| 21 |
PLUGIN_NAME = _("AWN Album Art Display") |
|---|
| 22 |
PLUGIN_DESC = "The cover image is shown in AWN's quodlibet icon" |
|---|
| 23 |
PLUGIN_VERSION = "0.1" |
|---|
| 24 |
def __init__(self): |
|---|
| 25 |
global awn |
|---|
| 26 |
bus_obj = dbus.SessionBus().get_object("com.google.code.Awn", "/com/google/code/Awn") |
|---|
| 27 |
awn = dbus.Interface(bus_obj, "com.google.code.Awn") |
|---|
| 28 |
def plugin_on_song_started(self, song): |
|---|
| 29 |
global awn |
|---|
| 30 |
if song is None: |
|---|
| 31 |
awn.UnsetTaskIconByName("quodlibet") |
|---|
| 32 |
else: |
|---|
| 33 |
cover = song.find_cover() |
|---|
| 34 |
if cover is None: |
|---|
| 35 |
awn.UnsetTaskIconByName("quodlibet") |
|---|
| 36 |
else: |
|---|
| 37 |
f = file(out, "wb") |
|---|
| 38 |
f.write(cover.read()) |
|---|
| 39 |
f.close() |
|---|
| 40 |
awn.SetTaskIconByName("quodlibet", out) |
|---|
| 41 |
def disabled(self): |
|---|
| 42 |
global awn |
|---|
| 43 |
awn.UnsetTaskIconByName("quodlibet") |
|---|
| 44 |
def destroy(self): |
|---|
| 45 |
global awn |
|---|
| 46 |
awn.UnsetTaskIconByName("quodlibet") |
|---|