Add lock.py to send custom lock and unlock messages.
This commit is contained in:
parent
d6b682bb60
commit
42661d863d
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import telegram
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
try:
|
||||
import config
|
||||
except ImportError:
|
||||
print("Missing Config. Exiting.")
|
||||
exit()
|
||||
|
||||
bot = telegram.Bot(token=config.api_key)
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print("Invalid number of parameters")
|
||||
exit(1)
|
||||
|
||||
arg = sys.argv[1]
|
||||
if arg == "lock":
|
||||
today = datetime.datetime.today()
|
||||
text = today.strftime(config.lock_message)
|
||||
bot.send_message(chat_id=config.master_id, text=text)
|
||||
elif arg == "unlock":
|
||||
today = datetime.datetime.today()
|
||||
text = today.strftime(config.lock_message)
|
||||
bot.send_message(chat_id=config.master_id, text=text)
|
||||
else:
|
||||
print("Wrong parameter. Exiting.")
|
||||
exit(1)
|
|
@ -13,3 +13,8 @@ lock = "xautolock -locknow"
|
|||
# Put the name of process that is running only when the screen is
|
||||
# locked.
|
||||
lock_process = "i3lock"
|
||||
|
||||
# Lock and unlock message. The date is parsed according to strftime.
|
||||
# Check man strftime or http://strftime.org/
|
||||
lock_message = "You have locked your system - %c"
|
||||
unlock_message = "You have unlocked your system - %c"
|
||||
|
|
Loading…
Reference in New Issue