Created
December 5, 2019 16:07
-
-
Save rugbymauri/453b7843449698284f80b7dcbd2c7c8e to your computer and use it in GitHub Desktop.
Punch Card
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
#!/bin/bash/ | |
## /usr/local/bin/punch.sh | |
if [ ! -d "/var/punchcard" ] | |
then | |
mkdir /var/punchcard | |
fi | |
echo "$1; $(date +"%d.%m.%Y %T"); $(hostname -I) " >> /var/punchcard/punchcard.txt | |
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
#!/bin/sh | |
## /usr/lib/systemd/system-sleep/punchcard | |
# script executes if sleep button is pressed | |
case $1 in | |
post) | |
sh /usr/local/bin/punch.sh IN | |
;; | |
pre) | |
sh /usr/local/bin/punch.sh OUT | |
;; | |
esac |
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/lib/systemd/system/punchcard.service | |
[Unit] | |
Description=Punchcard SService | |
[Service] | |
Type=oneshot | |
RemainAfterExit=true | |
ExecStart=sh /usr/local/bin/punch.sh IN | |
ExecStop=sh /usr/local/bin/punch.sh OUT | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment