Add timeking script
This commit is contained in:
parent
eb2f40a95d
commit
3fe2938b80
|
@ -42,6 +42,9 @@ ytmpv() {
|
|||
yt-dlp -q -o - "$1" | mpv -
|
||||
}
|
||||
|
||||
# timeking config
|
||||
alias newsboat="timeking '11:00-24:00' && newsboat"
|
||||
|
||||
goto() {
|
||||
open="$(grepa "$@" | fzf --ansi -1)"
|
||||
if [ ! -z "$open" ]; then
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/python3.9
|
||||
from datetime import datetime
|
||||
from sys import argv, stderr
|
||||
from os import system
|
||||
import re
|
||||
|
||||
rules = argv[1].split('&')
|
||||
|
||||
pattern = re.compile(r'(\d{2}):(\d{2})-(\d{2}):(\d{2})')
|
||||
now = datetime.now()
|
||||
|
||||
nm = now.hour * 60 + now.minute
|
||||
|
||||
for rule in rules:
|
||||
m = pattern.match(rule)
|
||||
if not m:
|
||||
print('unrecognized time stamp "{}"'.format(rule), file=stderr)
|
||||
exit(1)
|
||||
|
||||
sh, sm, eh, em = map(int, m.groups())
|
||||
|
||||
sm = sh * 60 + sm
|
||||
em = eh * 60 + em
|
||||
|
||||
if nm >= sm and nm <= em:
|
||||
exit(0)
|
||||
|
||||
print('You are not supposed to access this program now', file=stderr)
|
||||
system('notify-send -u critical "You are not supposed to access this program now"')
|
||||
exit(2)
|
Loading…
Reference in New Issue