Created
May 25, 2019 16:49
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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