Skip to content

Instantly share code, notes, and snippets.

@atomize
Created May 25, 2019 16:49
Show Gist options
  • Save atomize/c7e56f8f5d24244e5f2b01a7f2a3c45f to your computer and use it in GitHub Desktop.
Save atomize/c7e56f8f5d24244e5f2b01a7f2a3c45f to your computer and use it in GitHub Desktop.
Example of how to run a shell script based on xscreensaver daemon output.
#!/usr/bin/perl
my $blanked = 0;
open (IN, "xscreensaver-command -watch |");
while (<IN>) {
if (m/^(BLANK|LOCK)/) {
if (!$blanked) {
system "sound-off";
$blanked = 1;
}
} elsif (m/^UNBLANK/) {
system "sound-on";
$blanked = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment