Skip to content

Instantly share code, notes, and snippets.

@dictcp
Created March 2, 2014 09:30
Show Gist options
  • Save dictcp/9304059 to your computer and use it in GitHub Desktop.
Save dictcp/9304059 to your computer and use it in GitHub Desktop.
send SIGSTOP to firefox when the workstation is locked, in order to save the CPU power
#!/usr/bin/perl
my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'\"";
open (IN, "$cmd |");
while (<IN>) {
if (m/^\s+boolean true/) {
print "*** Screensaver is active ***\n";
system("killall -s SIGSTOP firefox plugin-container");
} elsif (m/^\s+boolean false/) {
print "*** Screensaver is no longer active ***\n";
system("killall -s SIGCONT firefox plugin-container");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment