diff --git a/i3-screenlayout-toggle b/i3-screenlayout-toggle new file mode 100755 index 0000000..210b2ca --- /dev/null +++ b/i3-screenlayout-toggle @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +import codecs +import glob +import os +import os.path +import sys + + +def main(): + screenlayout_dir = os.path.expanduser('~/.screenlayout') + if not os.path.isdir(screenlayout_dir): + os.makedirs(screenlayout_dir) + + profiles = [ + os.path.basename(f) + for f in glob.glob(os.path.join(screenlayout_dir, '*.sh')) + ] + if len(profiles) == 0: + return 0 + + cur_profile = profiles[0] + + cur_profile_path = os.path.join(screenlayout_dir, '.current') + if os.path.isfile(cur_profile_path): + with codecs.open(cur_profile_path, encoding='utf-8') as infile: + cur_profile = infile.read().strip() + + if cur_profile not in profiles: + print('ERROR:{}: current profile {} not found'.format(progname, + cur_profile), file=sys.stderr) + cur_profile = profiles[0] + + cur_idx = profiles.index(cur_profile) + next_idx = cur_idx + 1 + if next_idx >= (len(profiles) - 1): + next_idx = abs(next_idx - len(profiles)) + + next_profile = profiles[next_idx] + with codecs.open(cur_profile_path, 'w', encoding='utf-8') as outfile: + outfile.write(next_profile) + + os.execl(os.path.join(screenlayout_dir, next_profile), '--') + + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/i3/config b/i3/config index f741546..b7fef45 100644 --- a/i3/config +++ b/i3/config @@ -109,8 +109,10 @@ bindsym XF86AudioMute exec pactl set-sink-mute 0 toggle bindsym XF86MonBrightnessDown exec ~/.i3status-update-do xbacklight -5 bindsym XF86MonBrightnessUp exec ~/.i3status-update-do xbacklight +5 -bindsym XF86Calculator exec i3lock -c ed1c24 -bindsym XF86Tools exec xfce4-screenshooter +bindsym XF86Tools exec i3lock -c ed1c24 +bindsym XF86Calculator exec xcalc +bindsym XF86Display exec ~/.i3-screenlayout-toggle +bindsym Print exec xfce4-screenshooter # resize window (you can also use the mouse for that) mode "resize" {