Start and stop script with screensaver
Hello I would like to start and stop rtorrent based on my screensaver. I used to do this awhile ago with ubuntu and still have my script which may be helpful to someone else.
However now I am using Fedora with KDE and the script no longer seems to work. Could someone please help me with either another solutions or assist me in getting this to work: #!/usr/bin/perl #gnome my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\""; open (IN, "$cmd |"); while (<IN>) { if (m/^\s+boolean true/) { #when screensaver activates, run the following commands #system("/home/eric/compiled/scripts/rtorrentstart"); system("touch /home/asoukenka/rtorrenthasstarted"); } elsif (m/^\s+boolean false/) { #when screensaver deactivates, run the following commands #system("kill `pgrep rtorrent`"); system("touch /home/asoukenka/rtorrenthasbeenkilled"); } } just found my old post where some people helped me with this http://ubuntuforums.org/archive/index.php/t-977249.html |
For starters, the interface name needs to be changed since you are no longer using GNOME. Something like "org.kde.Screensaver"
Quote:
|
Thank you require further assistance though
Nevermind all is fixed now. For those who want it here is the final script.
#!/usr/bin/perl #requires: # rtorrent, screen, gnome/kde, perl # # Instructions: # - Properly comment the line for gnome or kde # - Give script execute permission (chmod +x) # - Run script ./<scriptname> **** do not use rtorrent in script name will mess up kill command # # There is a log file created by the script at /tmp/autortorrent # # #gnome #my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\""; #kde my $cmd = "dbus-monitor --session \"type='signal',interface='org.freedesktop.ScreenSaver',member='ActiveChanged'\""; open (IN, "$cmd |"); while (<IN>) { if (m/^\s+boolean true/) { #when screensaver activates, run the following commands system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent"); system("screen -dmS rtorrent rtorrent"); system("echo \"started:\" >> /tmp/autortorrent"); system("date >> /tmp/autortorrent"); system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent"); } elsif (m/^\s+boolean false/) { #when screensaver deactivates, run the following commands system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent"); system("kill `pgrep rtorrent`"); system("echo \"stopped:\" >> /tmp/autortorrent"); system("date >> /tmp/autortorrent"); #system("ps aux |grep rtorrent >> /tmp/autortorrent"); system("echo \"--------------------------------------------------------------------\" >> /tmp/autortorrent"); } } |
Hello,
I slightly modified your code to have Kopete disconnected on screen saver start and reconnect when screen saver unlock... Code:
#!/usr/bin/perl |
All times are GMT -5. The time now is 05:54 PM. |