Add lock.py to send custom lock and unlock messages.

This commit is contained in:
Ceda EI 2018-10-04 01:28:28 +05:30
parent d6b682bb60
commit 42661d863d
2 changed files with 35 additions and 0 deletions

30
lock.py Normal file
View File

@ -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)

View File

@ -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"