ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Here's my situation: I've written a python-based amarok script to make a libnotify popup whenever the track changes.
I've written this script because the current "standard" libnotify script is a bash script that doesn't handle things such as parentheses and slashes well, and additionally I wanted to do some more advanced imaging to the cover image.
To make a long story short, I also use WICD (which too is based on python) to connect to wireless networks.
It seems that WICD and Amarok are fighting in that whenever I reconnect to a wireless network, amarok stutters if it's playing. I have, however verified that my script is causing this--no stutter if I stop it from running. Therefore, I have concluded that it is python causing the issue.
To that end, my script uses sys.stdin.readline() (it was using raw_input()) to talk to amarok (which sends commands to scripts via stdin), if it matters, but I'm looking to solve this. I can provide the script if necessary.
import sys, threading, pydcop, pynotify, Image, ImageDraw
from cgi import escape
amarok = pydcop.anyAppCalled("amarok")
cmd = sys.stdin.readline()
title = escape(amarok.player.title())
artist = escape(amarok.player.artist())
album = escape(amarok.player.album())
cover = amarok.player.coverImage()
coverImg = Image.open(cover)
coverImg.thumbnail((64, 64), Image.ANTIALIAS)
coverDraw = ImageDraw.Draw(coverImg)
coverDraw.rectangle([(0, 0), (coverImg.size-1, coverImg.size-1)], outline=(0))
cover = "/tmp/amarok-notify.png"
cover = "file://" + cover
if cmd == "configure":
amarok.playlist.popupMessage("This script does not have any configuration options")
elif cmd == "engineStateChange: playing\n":
n = pynotify.Notification("Amarok Playing", "<b>" + title + "</b> by <b>" + artist + "</b> on <b>" + album + "</b>", cover)
elif cmd == "engineStateChange: paused\n":
n = pynotify.Notification("Amarok Paused", "<b>" + title + "</b> by <b>" + artist + "</b> on <b>" + album + "</b>", cover)
if __name__ == "__main__":
t = threading.Thread(target=readloop)
After some more experimentation, it seems more likely that it was the awn icon script, not the python script, but I digress... for completeness, here's my script. I added the bit for threading on the end in an attempt to alleviate the issue. Didn't really work.