Wednesday, December 12, 2012

Run Screensaver & Music Player from Thunar's File Manager

In my opinion, a screensaver begins and ends with a slideshow featuring beautiful specimens from the realms of art and imagination, nature, and science. I will never understand why so many people opt for alternative solutions such as using a non-slideshow screensaver (called a "visualizer") from within a media player. Configure the screensaver within the operating system but once, and it will function with and without the media player. Pictures appealing to one's personal taste may be obtained quite easily by anyone with Internet access, patience, and storage space. So why use anything else in a screensaver--ever?

When I play music on my media player, I want the desktop to display my slideshow. I do not want VLC to run a tacky visualizer. And I want to use nothing within VLC, but instead the regular desktop screensaver-slideshow, which can be easily deactivated by moving the mouse or pressing any key and which I have configured to my own preferences.

The following custom command, when selected in Thunar, passes selected files and folders to VLC and then, after a five second pause, activates the screensaver. I don't see any reason why this technique would not work in other Linux desktop environments, but I haven't tested it, so I will say, caveat emptor. My own desktop environment is Xfce running on Linux Mint Maya. I have VLC and xscreensaver installed and working, although the logic below could be adapted for other media players and other screensavers.

In Xfce's File Manager, Thunar, click Edit | Configure Custom Actions, and then choose the + icon to add a new one. For the name of the action, let's type "Play in VLC & Run Screensaver," and for the command, "/bin/vlcs.sh %F", which loads a shell script while passing a variable consisting of selected files and folders. Executing a script is indeed necessary, because Thunar seems to not permit multiple commands in a custom action. Perhaps in gnome or kde, the story may be different--experiment and see whether this is so. Of course one would rather not have to create a new batch file just to execute two or three commands.

The shell script, which I call /bin/vlcs.sh, consists of just two lines:

#!bin/sh
vlc "$1" & sleep 5 && xscreensaver-command -activate
Name this Linux shell script "vlcs.sh", place it in the /bin folder, and set the execute bit using "chmod a+x /bin/vlcs.sh" so that all may execute it. I'm not a big security buff, but if you are, then set the security however you like it, just so that it can execute from the File Manager.

VLC and the sleep command execute at the same time. The sleep command waits for five seconds. Only after the sleep command has finished do I want the screensaver to activate and display my slideshow. I find the delay helpful, because without it, the screensaver executes with such alacrity that my hand cannot remove itself from the mouse fast enough to avoid deactivating the screensaver. Besides, I like to observe VLC's playlist for a moment before it runs. Many a time during testing, I passed an invalid variable to VLC, and it got stuck in an endless loop trying to load invalid file names, which is not very intelligent, to say the least. I tried to add some audits of the variable inside the script, but I cannot add any if...then commands to the batch, otherwise it won't work at all from within Thunar in Xubuntu 12.10. The batch must remain primitive for reasons that are unclear to me. I am sure the solution is something simple that the experts have neglected to mention because they feel it is obvious. At any rate, I was pleased to set this up, because it saves me a step during dinner parties.Post a Comment
by igor 04:20 4 replies by igor 09:32 0 comments

No comments:

techlorebyigor is my personal journal for ideas & opinions