i3pystatus: add magic link option to check in to travelynx
This commit is contained in:
parent
92280706ee
commit
cd6ada85d9
2 changed files with 15 additions and 1 deletions
|
@ -89,6 +89,7 @@ status.register("shell",
|
||||||
format="{output}",
|
format="{output}",
|
||||||
hints = {"markup": "pango"},
|
hints = {"markup": "pango"},
|
||||||
command="/home/kunsi/.config/i3pystatus/ice-status.py",
|
command="/home/kunsi/.config/i3pystatus/ice-status.py",
|
||||||
|
on_leftclick="/home/kunsi/.config/i3pystatus/ice-status.py --link",
|
||||||
ignore_empty_stdout=True,
|
ignore_empty_stdout=True,
|
||||||
interval=2)
|
interval=2)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,11 @@
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from requests import get
|
from requests import get
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
from sys import exit
|
from sys import argv, exit
|
||||||
|
|
||||||
|
LINK_MODE = False
|
||||||
|
if len(argv) > 1 and argv[1] == '--link':
|
||||||
|
LINK_MODE = True
|
||||||
|
|
||||||
|
|
||||||
# bundlewrap.utils.text.format_duration, but trimmed down
|
# bundlewrap.utils.text.format_duration, but trimmed down
|
||||||
|
@ -44,9 +48,18 @@ try:
|
||||||
ice_status_req.raise_for_status()
|
ice_status_req.raise_for_status()
|
||||||
ice_status = ice_status_req.json()
|
ice_status = ice_status_req.json()
|
||||||
|
|
||||||
|
if LINK_MODE:
|
||||||
|
check_output(['xdg-open', 'https://travelynx.franzi.business/s/{}?train={}%20{}'.format(
|
||||||
|
trip_info['stopInfo']['actualLast'],
|
||||||
|
trip_info['trainType'],
|
||||||
|
trip_info['vzn'],
|
||||||
|
)])
|
||||||
|
exit(0)
|
||||||
|
|
||||||
next_stop_id = trip_info['stopInfo']['actualNext']
|
next_stop_id = trip_info['stopInfo']['actualNext']
|
||||||
for stop in trip_info['stops']:
|
for stop in trip_info['stops']:
|
||||||
if stop['station']['evaNr'] == next_stop_id:
|
if stop['station']['evaNr'] == next_stop_id:
|
||||||
|
|
||||||
if stop['timetable']['departureDelay']:
|
if stop['timetable']['departureDelay']:
|
||||||
delay = ' | <span color="#FF0000">{}</span>'.format(stop['timetable']['departureDelay'])
|
delay = ' | <span color="#FF0000">{}</span>'.format(stop['timetable']['departureDelay'])
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue