LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 05-26-2009, 12:19 AM   #1
esoukenka
LQ Newbie
 
Registered: Feb 2009
Posts: 19

Rep: Reputation: 2
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

Last edited by esoukenka; 05-26-2009 at 12:25 AM.
 
Old 05-26-2009, 08:38 AM   #2
fpmurphy
Member
 
Registered: Jan 2009
Location: /dev/ph
Distribution: Fedora, Ubuntu, Redhat, Centos
Posts: 299

Rep: Reputation: 62
For starters, the interface name needs to be changed since you are no longer using GNOME. Something like "org.kde.Screensaver"
Quote:
my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='SessionIdleChanged'\"";
Use qdbus or qdbusviewer to figure out the exact object and method names.
 
1 members found this post helpful.
Old 05-26-2009, 12:55 PM   #3
esoukenka
LQ Newbie
 
Registered: Feb 2009
Posts: 19

Original Poster
Rep: Reputation: 2
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");
}
}

Last edited by esoukenka; 05-27-2009 at 11:46 AM.
 
1 members found this post helpful.
Old 11-08-2011, 06:04 AM   #4
karlacio
LQ Newbie
 
Registered: Jan 2009
Posts: 1

Rep: Reputation: 0
Hello,

I slightly modified your code to have Kopete disconnected on screen saver start and reconnect when screen saver unlock...



Code:
#!/usr/bin/perl


#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'\"";
#my $cmd = "dbus-monitor --session \"type='signal'\"";
print "---$cmd----\n";
#exit;


open (IN, "$cmd |");

while (<IN>) {
  if (m/^\s+boolean true/) {
    #when screensaver activates, run the following commands
    system("dbus-send --type=method_call --dest=org.kde.kopete /Kopete org.kde.Kopete.disconnectAll");
    print "Kopete disconnected\n";
  } elsif (m/^\s+boolean false/) {
    #when screensaver deactivates, run the following commands
    system("dbus-send --type=method_call --dest=org.kde.kopete /Kopete org.kde.Kopete.connectAll");
    print "Kopete connected\n";
  }
}
 
  


Reply

Tags
dbus, kde


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'simple' script help needed (start/stop program) powadha Linux - Software 1 03-26-2009 01:44 PM
AWK- processing data inside start/stop pairs but ignoring start/stop lines cliffoij Programming 2 10-15-2008 06:17 AM
custom init.d script will start but won't stop Qwerty9119 Red Hat 2 05-03-2007 12:51 PM
custom init.d script will start but won't stop Qwerty9119 Linux - General 2 05-03-2007 12:23 PM
using cron to start and stop a bash script monty Linux - Software 2 03-20-2006 02:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 03:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration