Skip to content

Instantly share code, notes, and snippets.

@bartman
Last active December 7, 2018 19:09
Show Gist options
  • Save bartman/4f8420eb55601c594289 to your computer and use it in GitHub Desktop.
Save bartman/4f8420eb55601c594289 to your computer and use it in GitHub Desktop.
i3
#!/bin/bash
gnome-screensaver&
xsetroot -solid '#101010' &
brightness 100
xset b off
xrandr --output DP1 --primary
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod1
set $mod2 Mod4
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below. ISO 10646 = Unicode
#font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
font -windows-proggytiny-medium-r-normal--10-80-96-96-c-60-iso8859-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, if you need a lot of unicode glyphs or
# right-to-left text rendering, you should instead use pango for rendering and
# chose an xft font, such as:
# font xft:DejaVu Sans Mono 10
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
#default_orientation vertical
#workspace_layout stacking
# start a terminal
bindsym $mod+Return exec --no-startup-id i3-sensible-terminal
# kill focused window
bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
#bindsym $mod+p exec --no-startup-id dmenu_run
bindsym $mod+p exec --no-startup-id rofi -show run
bindsym $mod+Shift+p exec --no-startup-id rofi -show drun
# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right
# alternatively, you can use the cursor keys:
#bindsym $mod+Left focus left
#bindsym $mod+Down focus down
#bindsym $mod+Up focus up
#bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right
# find a window
#bindsym $mod+f exec --no-startup-id ~/.i3/get_window_list.py | dmenu -b | ~/.i3/focus_window_named.py
bindsym $mod+f exec --no-startup-id rofi -show window
# split in horizontal orientation
bindsym $mod+semicolon split h
# split in vertical orientation
bindsym $mod+v split v
# enter fullscreen mode for the focused container
bindsym $mod+Shift+f fullscreen
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
bindsym $mod+d focus child
# switch to workspace
bindsym $mod2+1 workspace 1
bindsym $mod2+2 workspace 2
bindsym $mod2+3 workspace 3
bindsym $mod2+4 workspace 4
bindsym $mod2+5 workspace 5
bindsym $mod2+6 workspace 6
bindsym $mod2+7 workspace 7
bindsym $mod2+8 workspace 8
bindsym $mod2+9 workspace 9
bindsym $mod2+0 workspace 10
# move focused container to workspace
bindsym $mod2+Shift+1 move container to workspace 1
bindsym $mod2+Shift+2 move container to workspace 2
bindsym $mod2+Shift+3 move container to workspace 3
bindsym $mod2+Shift+4 move container to workspace 4
bindsym $mod2+Shift+5 move container to workspace 5
bindsym $mod2+Shift+6 move container to workspace 6
bindsym $mod2+Shift+7 move container to workspace 7
bindsym $mod2+Shift+8 move container to workspace 8
bindsym $mod2+Shift+9 move container to workspace 9
bindsym $mod2+Shift+0 move container to workspace 10
# $ for n ( {a..z} ) echo "bindsym \$mod2+$n exec --no-startup-id ~/.i3/go_to_workspace.py $n"
bindsym $mod2+a exec --no-startup-id ~/.i3/go_to_workspace.py a
bindsym $mod2+b exec --no-startup-id ~/.i3/go_to_workspace.py b
bindsym $mod2+c exec --no-startup-id ~/.i3/go_to_workspace.py c
bindsym $mod2+d exec --no-startup-id ~/.i3/go_to_workspace.py d
bindsym $mod2+e exec --no-startup-id ~/.i3/go_to_workspace.py e
bindsym $mod2+f exec --no-startup-id ~/.i3/go_to_workspace.py f
bindsym $mod2+g exec --no-startup-id ~/.i3/go_to_workspace.py g
bindsym $mod2+h exec --no-startup-id ~/.i3/go_to_workspace.py h
bindsym $mod2+i exec --no-startup-id ~/.i3/go_to_workspace.py i
bindsym $mod2+j exec --no-startup-id ~/.i3/go_to_workspace.py j
bindsym $mod2+k exec --no-startup-id ~/.i3/go_to_workspace.py k
bindsym $mod2+l exec --no-startup-id ~/.i3/go_to_workspace.py l
bindsym $mod2+m exec --no-startup-id ~/.i3/go_to_workspace.py m
bindsym $mod2+n exec --no-startup-id ~/.i3/go_to_workspace.py n
bindsym $mod2+o exec --no-startup-id ~/.i3/go_to_workspace.py o
bindsym $mod2+p exec --no-startup-id ~/.i3/go_to_workspace.py p
bindsym $mod2+q exec --no-startup-id ~/.i3/go_to_workspace.py q
bindsym $mod2+r exec --no-startup-id ~/.i3/go_to_workspace.py r
bindsym $mod2+s exec --no-startup-id ~/.i3/go_to_workspace.py s
bindsym $mod2+t exec --no-startup-id ~/.i3/go_to_workspace.py t
bindsym $mod2+u exec --no-startup-id ~/.i3/go_to_workspace.py u
bindsym $mod2+v exec --no-startup-id ~/.i3/go_to_workspace.py v
bindsym $mod2+w exec --no-startup-id ~/.i3/go_to_workspace.py w
bindsym $mod2+x exec --no-startup-id ~/.i3/go_to_workspace.py x
bindsym $mod2+y exec --no-startup-id ~/.i3/go_to_workspace.py y
bindsym $mod2+z exec --no-startup-id ~/.i3/go_to_workspace.py z
# goto the previous workspace
bindsym $mod+r workspace back_and_forth
# alt-[,.] shows prev/next workspace #TODO: this should be per-screen, not global (need to write some python)
#bindsym $mod+comma workspace prev
#bindsym $mod+period workspace next
#bindsym $mod+comma workspace prev_on_output
#bindsym $mod+period workspace next_on_output
bindsym $mod+comma exec --no-startup-id ~/.i3/go_to_workspace.py -- -1
bindsym $mod+period exec --no-startup-id ~/.i3/go_to_workspace.py -- 1
# win-[,.] focuses the other screen
bindsym $mod2+comma focus output left
bindsym $mod2+period focus output right
# alt-tab emulate toggling, may need to write some python to support >2 screens
bindsym $mod+Tab focus output left
# alt-shift-[,.] moves workspace to the other screen
bindsym $mod+Shift+comma exec --no-startup-id i3-msg move workspace to output left
bindsym $mod+Shift+period exec --no-startup-id i3-msg move workspace to output right
# http://www.blog.kaiserapps.com/2014/02/my-killer-i3-setup.html
# http://www.blog.kaiserapps.com/2014/02/dynamic-tagging-in-i3.html
# https://gist.github.com/benkaiser/8822222
bindsym $mod+t exec --no-startup-id ~/.i3/get_workspace_options.py | rofi -dmenu -p go-to | ~/.i3/go_to_workspace.py
bindsym $mod+Shift+t exec --no-startup-id ~/.i3/get_workspace_options.py | rofi -dmenu -p move-to | ~/.i3/move_to_workspace.py
bindsym $mod+Shift+b exec --no-startup-id x-www-browser
bindsym $mod+b exec --no-startup-id x-www-browser "$(xclip -o)"
bindsym $mod+Shift+v exec --no-startup-id vim-anywhere
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Control+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec --no-startup-id "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
## Colors
## class border background text
client.focused #9966CC #9966CC #000000
client.focused_inactive #333333 #333333 #999999
client.unfocused #333333 #333333 #999999
client.urgent #FF0000 #8C5665 #999999
#bar.focused #DA6F00 #000000 #999999
#bar.unfocused #333333 #000000 #999999
#bar.urgent #FF0000 #000000 #999999
workspace 1 output LVDS1
workspace 2 output LVDS1
workspace 9 output DP1
workspace "10: www" output DP1
bindsym $mod+ctrl+b border toggle
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -5%
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +5%
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle
bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight -inc 20
bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -dec 20
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the window’s width.
# Pressing right will grow the window’s width.
# Pressing up will shrink the window’s height.
# Pressing down will grow the window’s height.
bindsym h resize shrink width 5 px or 5 ppt
bindsym j resize grow height 5 px or 5 ppt
bindsym k resize shrink height 5 px or 5 ppt
bindsym l resize grow width 5 px or 5 ppt
# same bindings, but for the arrow keys
#bindsym Left resize shrink width 10 px or 10 ppt
#bindsym Down resize grow height 10 px or 10 ppt
#bindsym Up resize shrink height 10 px or 10 ppt
#bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+Shift+s mode "resize"
mode "(s)leep (h)ybernate (p)owersave (r)estart shut(d)own" {
bindsym s exec --no-startup-id sudo pm-suspend; mode "default"
bindsym h exec --no-startup-id sudo pm-hibernate; mode "default"
bindsym p exec --no-startup-id sudo pm-powersave; mode "default"
bindsym d exec --no-startup-id sudo 'shutdown -h now'; mode "default"
bindsym r exec --no-startup-id sudo 'shutdown -r now'; mode "default"
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+Shift+n mode "(s)leep (h)ybernate (p)owersave (r)estart shut(d)own"
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
mode dock
#i3bar_command /usr/bin/i3bar
i3bar_command /home/carbon/bart/src/i3/i3/build/i3bar/i3bar
status_command LC_ALL=C i3status --config ~/.i3/i3status.conf
strip_workspace_numbers yes
tray_output primary
#verbose yes
#font pango:Hack, FontAwesome 10
}
#for_window [class="^Google-chrome$"] border pixel
for_window [title="Google Chrome$"] border pixel
for_window [window_type="notification"] floating enable
# https://gist.github.com/AlexanderPavlenko/04078f90c6b127926218
for_window [class="plasmashell"] floating enable;
for_window [class="Plasma"] floating enable; border none
for_window [title="plasma-desktop"] floating enable; border none
for_window [class="krunner"] floating enable; border none
for_window [class="Kmix"] floating enable; border none
for_window [class="Klipper"] floating enable; border none
for_window [class="Plasmoidviewer"] floating enable; border none
for_window [title="win7"] floating enable; border none
for_window [title="^Steam$"] workspace game; border pixel 1
for_window [title="^Steam$"] move container to workspace game
for_window [title="^Civilization VI$"] workspace game; border pixel 1
for_window [title="^Civilization VI$"] move container to workspace game
for_window [title="YakYak"] workspace 1; border pixel 1
for_window [title="Google Hangouts"] workspace 1; border pixel 1
for_window [title="Google Hangouts"] move container to workspace 1
#fow_window [class="Google-chrom" window_role="pop-up"] floating enable; border pixel 1
## Plasma Integration
## https://github.com/avivace/dotfiles/blob/master/.config/i3/config
## Try to kill the wallpaper set by Plasma (it takes up the entire workspace and hides everythiing)
exec --no-startup-id wmctrl -c Plasma
for_window [title="Desktop — Plasma"] kill; floating enable; border none
## tint the screen
exec --no-startup-id pidof redshift || redshift-gtk -l 45.366933:-75.741977
exec --no-startup-id ./.screenlayout/default.sh
## Avoid tiling popups, dropdown windows from plasma
## for the first time, manually resize them, i3 will remember the setting for floating windows
#for_window [class="plasmashell"] floating enable;
#for_window [class="Plasma"] floating enable; border none
#for_window [title="plasma-desktop"] floating enable; border none
#for_window [title="win7"] floating enable; border none
#for_window [class="krunner"] floating enable; border none
#for_window [class="Kmix"] floating enable; border none
#for_window [class="Klipper"] floating enable; border none
#for_window [class="Plasmoidviewer"] floating enable; border none
#!/usr/bin/python3
import json
import re
import subprocess
import sys
I3MSG = 'i3-msg'
#I3MSG = '/usr/bin/i3-msg'
windows = []
def get_pattern():
return str(sys.stdin.readlines()[0]).strip()
def get_tree():
test = subprocess.Popen(["i3-msg","-t","get_tree"], stdout=subprocess.PIPE)
output = test.communicate()[0]
return json.loads(output.decode())
def walk_tree(tree):
if tree['window']:
#print("+ "+tree['name'])
windows.append({
'name': tree['name'],
'id': str(tree['id']),
'focused': tree['focused']
})
if len(tree['nodes']) > 0:
for node in tree['nodes']:
walk_tree(node)
def filter_windows(pattern):
found = list(filter(lambda x: re.search(pattern, x['name']), windows))
if len(found) > 0:
return found
found = list(filter(lambda x: re.search(pattern, x['name'], flags=re.IGNORECASE), windows))
if len(found) > 0:
return found
print("# no match '%s'"%str(pattern))
sys.exit()
def main():
pattern = get_pattern()
#print(" pattern '"+str(pattern)+"'")
tree = get_tree()
walk_tree(tree)
#print(" windows "+str(windows))
#print(" ...size "+str(len(windows)))
focused = False
#focused = filter(lambda x: x['focused'], windows)
#print(" focused "+str(focused))
#if len(focused) == 1:
# focused = focused[0]
#else:
# focused = False
filteredWindows = filter_windows(pattern)
#print(" filteredWindows "+str(filteredWindows))
#print(" ...size "+str(len(filteredWindows)))
if len(filteredWindows) == 0:
sys.exit()
print("# matched %u windows"%len(filteredWindows))
nextWindow = False
try:
if not focused:
raise ValueError
nextIndex = filteredWindows.index(focused) + 1
if nextIndex == len(filteredWindows):
raise ValueError
else:
nextWindow = filteredWindows[nextIndex]
except ValueError:
nextWindow = filteredWindows[0]
con_id = nextWindow['id']
subprocess.call([I3MSG, '[con_id=' + con_id + ']', 'focus'])
if __name__ == '__main__':
main()
#!/usr/bin/python3
import subprocess
import json
windows = []
def walk_tree(tree):
if tree['window']:
#print(tree['window'])
print(" %s"%tree['window_properties']['title'])
windows.append({'window': str(tree['window']),
'focused': tree['focused']})
if len(tree['nodes']) > 0:
for node in tree['nodes']:
walk_tree(node)
test = subprocess.Popen(["i3-msg","-t","get_tree"], stdout=subprocess.PIPE)
output = test.communicate()[0]
data = json.loads(output.decode())
walk_tree(data)
#!/usr/bin/python3
import subprocess
import json
test = subprocess.Popen(["i3-msg","-t","get_workspaces"], stdout=subprocess.PIPE)
output = test.communicate()[0]
data = json.loads(output.decode())
#def ws_cmp(a,b):
# return a['name'] < b['name']
#data = sorted(data, cmp=ws_cmp)
data = sorted(data, key=lambda k: k['name'])
for i in data:
print(i['name'])
#!/usr/bin/python3
import subprocess
import json
import sys
import re
def get_workspaces():
test = subprocess.Popen(["i3-msg","-t","get_workspaces"], stdout=subprocess.PIPE)
output = test.communicate()[0]
workspaces = json.loads(output.decode())
return workspaces
def get_current(workspaces,name):
current = list(filter(lambda i: i['focused'], workspaces))
return current[0][name]
def get_workspaces_on_current_output(workspaces):
cur_output = get_current(workspaces,'output')
ws_output = list(filter(lambda i: i['output'] == cur_output, workspaces))
ws_names = sorted(map(lambda i: i['name'], ws_output))
#if len(ws_names) < 1:
#ws_names = sorted(map(lambda i: i['name'], workspaces))
return ws_names
def get_ws_matching(req):
workspaces = get_workspaces()
ws_names = get_workspaces_on_current_output(workspaces)
lead_re = re.compile(r'^%s'%req)
lead_names = list(filter(lead_re.search, ws_names))
mid_re = re.compile(r'^[^%s]+%s'%(req,req))
mid_names = list(filter(mid_re.search, ws_names))
names = lead_names + mid_names
if len(names) > 1:
try:
cur_name = get_current(workspaces,'name')
found = names.index(cur_name)
names = names[found+1:] + names[0:found]
except ValueError:
pass
return names[0]
def get_ws_dir(direction):
workspaces = get_workspaces()
names = get_workspaces_on_current_output(workspaces)
if len(names) < 2:
return names[0]
cur_name = get_current(workspaces,'name')
try:
found = names.index(cur_name)
count = len(names)
want = (found + direction + count) % count
return names[want]
except ValueError:
pass
return cur_name
if len(sys.argv) > 1:
req = sys.argv[1]
if req != '--':
name = get_ws_matching(req)
else:
direction = int(sys.argv[2])
name = get_ws_dir(direction)
else:
name = sys.stdin.readlines()[0]
if len(name) > 0:
test = subprocess.Popen(["i3-msg","workspace "+name], stdout=subprocess.PIPE)
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
interval = 5
}
order += "ipv6"
order += "disk /"
order += "disk /data"
order += "run_watch DHCP"
#order += "run_watch VPN"
#order += "wireless wlan0"
order += "ethernet eth0"
order += "cpu_temperature 1"
#order += "battery 0"
order += "load"
order += "tztime local"
wireless wlan0 {
format_up = "W: (%quality at %essid) %ip"
format_down = "W: down"
}
ethernet eth0 {
# if you use %speed, i3status requires root privileges
format_up = "E: %ip (%speed)"
format_down = "E: down"
}
battery 0 {
format = "%status %percentage %remaining"
}
cpu_temperature 1 {
format = "%degrees°C"
#path = "/sys/devices/platform/coretemp.0/temp1_input"
path = "/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp1_input"
}
run_watch DHCP {
pidfile = "/var/run/dhclient*.pid"
}
run_watch VPN {
pidfile = "/var/run/vpnc/pid"
}
tztime local {
format = "%Y-%m-%d %H:%M:%S"
}
load {
format = "%1min"
}
disk "/" {
format = "%avail"
}
disk "/data" {
format = "%avail"
}
#!/usr/bin/python3
import subprocess
import sys
data = sys.stdin.readlines()[0]
test = subprocess.Popen(["i3-msg","move container to workspace "+data], stdout=subprocess.PIPE)
#!/usr/bin/python3
#
# https://faq.i3wm.org/question/2473/run-or-focus-in-i3/
#
# I use it in my configuration like this:
#
# bindsym F1 exec python ~/.i3/scripts/next_window.py "Chrome$" google-chrome
# bindsym F2 exec python ~/.i3/scripts/next_window.py "Sublime Text 2$" sublime-text
#
# The first parameter is a regex to match the window title. The second
# parameter is the application to launch if no active window is found.
import json
import re
import subprocess
import sys
I3MSG = '/usr/bin/i3-msg'
windows = []
def parse_args():
if len(sys.argv) == 3:
return (sys.argv[1], sys.argv[2])
else:
sys.exit('Must provide 2 arguments.')
def get_tree():
process = subprocess.Popen([I3MSG, "-t", "get_tree"], stdout=subprocess.PIPE)
tree = str(process.communicate()[0])
process.stdout.close()
return json.loads(tree)
def walk_tree(tree):
if tree['window']:
windows.append({
'name': tree['name'],
'id': str(tree['id']),
'focused': tree['focused']
})
if len(tree['nodes']) > 0:
for node in tree['nodes']:
walk_tree(node)
def main():
pattern, command = parse_args()
tree = get_tree()
walk_tree(tree)
focused = filter(lambda x: x['focused'], windows)
if len(focused) == 1:
focused = focused[0]
else:
focused = False
filteredWindows = filter(lambda x: re.search(pattern, x['name']), windows)
if len(filteredWindows) == 0:
subprocess.call([I3MSG, 'exec', '--no-startup-id', command])
else:
nextWindow = False
try:
if not focused:
raise ValueError
nextIndex = filteredWindows.index(focused) + 1
if nextIndex == len(filteredWindows):
raise ValueError
else:
nextWindow = filteredWindows[nextIndex]
except ValueError:
nextWindow = filteredWindows[0]
con_id = nextWindow['id']
subprocess.call([I3MSG, '[con_id=' + con_id + ']', 'focus'])
if __name__ == '__main__':
main()
i3-msg rename workspace abc to xyz
#!/bin/bash
killall i3bar
i3bar --bar_id=bar-0 --socket=$( i3 --get-socketpath )
#!/usr/bin/python3
#
# https://faq.i3wm.org/question/2473/run-or-focus-in-i3/
#
# I wanted something that's similar to awesome's RoR. That is, matching by
# class and cycling through matching windows. gustavnikolaj's solution matches
# by window title, which I didn't want, so I wrote this (the walk_tree function
# is from his script).
#
# Save it in e.g. ~.i3/runorfocus.py. To use it, just call the script (first
# argument is the class to match, the second argument is the program to launch
# if no matching window is found):
#
# bindsym $mod+w exec python ~/.i3/runorfocus.py "Firefox" firefox
#
# Note that you need xdotool to use the script.
import json
import subprocess
import sys
def get_output(cmd):
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
out = process.communicate()[0].decode()
process.stdout.close()
return out
def get_tree():
cmd = ["i3-msg", "-t", "get_tree"]
return json.loads(get_output(cmd))
def get_matching_class():
cmd = ["xdotool", "search", "--class", sys.argv[1]]
return get_output(cmd).split('\n')
windows = []
def walk_tree(tree):
if tree['window']:
windows.append({'window': str(tree['window']),
'focused': tree['focused']})
if len(tree['nodes']) > 0:
for node in tree['nodes']:
walk_tree(node)
def get_matches():
matches = []
tree = get_tree()
check = get_matching_class()
walk_tree(tree)
for window in windows:
for winid in check:
if window['window'] == winid:
matches.append(window)
return matches
def main():
matches = get_matches()
# Sort the list by window IDs
matches = [(match['window'], match) for match in matches]
matches.sort()
matches = [match for (key, match) in matches]
# Iterate over the matches to find the first focused one, then focus the
# next one.
for ind, match in enumerate(matches):
if match['focused'] == True:
subprocess.call(["i3-msg", "[id=%s] focus" % matches[(ind+1)%len(matches)]['window']])
return
# No focused match was found, so focus the first one
if len(matches) > 0:
subprocess.call(["i3-msg", "[id=%s] focus" % matches[0]['window']])
return
# No matches found, launch program
subprocess.call(["i3-msg", "exec", "--no-startup-id", sys.argv[2]])
if __name__ == '__main__':
main()
#!/bin/bash
set -e -x
layout=$HOME/.i3/layout
mkdir -p $layout
for output in $( xrandr --current | sed -rne 's/^(.*) connected.*/\1/p' ) ; do
i3-save-tree --output=$output > $layout/$output
done
#!/usr/bin/python3
import subprocess
import json
test = subprocess.Popen(["i3-msg","-t","get_tree"], stdout=subprocess.PIPE)
output = test.communicate()[0]
data = json.loads(output.decode())
#print(json.dumps(data, sort_keys=True, indent=2, separators=(',',': ')))
windows = []
def walk_tree(tree):
if tree['window']:
print(tree['window'])
print(" %s"%tree['window_properties']['title'])
windows.append({'window': str(tree['window']),
'focused': tree['focused']})
if len(tree['nodes']) > 0:
for node in tree['nodes']:
walk_tree(node)
walk_tree(data)
#data = sorted(data, key=lambda k: k['name'])
#for i in data:
# print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment