Skip to content

Instantly share code, notes, and snippets.

@lusis
Created August 24, 2016 12:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lusis/f219f146af6addf086917c90899ee441 to your computer and use it in GitHub Desktop.
Save lusis/f219f146af6addf086917c90899ee441 to your computer and use it in GitHub Desktop.
  • install gcalcli and connect it up to your account (gcalcli agenda after install should start the auth process)
  • write the python file above to somewhere (I use ~/.i3/cal_wrapper.py)
  • setup your ~/.i3/config with the status_command above
  • reload i3

optional

I added the following cron entry to alert via notify-send and dunst gives me warnings */5 * * * * gcalcli remind

#!/usr/bin/env python
import sys
import json
import subprocess
def get_next_meeting():
return subprocess.check_output("gcalcli --nostarted --nocolor agenda | head -2 | tail -1",
shell=True).rstrip()
def print_line(message):
""" Non-buffered printing to stdout. """
sys.stdout.write(message + '\n')
sys.stdout.flush()
def read_line():
""" Interrupted respecting reader for stdin. """
# try reading a line, removing any extra whitespace
try:
line = sys.stdin.readline().strip()
# i3status sends EOF, or an empty line
if not line:
sys.exit(3)
return line
# exit on ctrl-c
except KeyboardInterrupt:
sys.exit()
if __name__ == '__main__':
# Skip the first line which contains the version header.
print_line(read_line())
# The second line contains the start of the infinite array.
print_line(read_line())
while True:
line, prefix = read_line(), ''
# ignore comma at start of lines
if line.startswith(','):
line, prefix = line[1:], ','
j = json.loads(line)
# insert information into the start of the json, but could be anywhere
# CHANGE THIS LINE TO INSERT SOMETHING ELSE
#j.insert(0, {'full_text' : '%s' % get_governor(), 'name' : 'gov'})
j.insert(0, {
'full_text' : ' %s' % get_next_meeting(),
'name' : 'agenda',
'color' : '#FFC671'
})
# and echo back new encoded json
print_line(prefix+json.dumps(j))
bar {
separator_symbol "¦"
status_command i3status | ~/.i3/cal_wrapper.py
position bottom
font pango:FontAwesome 14
colors {
background #073642
statusline #839496
separator #b58900
# class border backgrd text
focused_workspace #cb4b16 #cb4b16 #ffffff
active_workspace #cb4b16 #cb4b16 #ffffff
inactive_workspace #252525 #252525 #6b6b6b
urgent_workspace #252525 #252525 #c7a551
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment