Browse Source

Moved to new and improved python i3 library

master
Micah Halter 2 years ago
parent
commit
82c480af2d
  1. 2
      Makefile
  2. 62
      scripts/.config/Scripts/i3-focus
  3. 31
      scripts/.config/Scripts/i3-workspaceswap
  4. 2
      zathura/.config/zathura/zathurarc

2
Makefile

@ -102,7 +102,6 @@ arch: pacman
pulseaudio-alsa \
pygmentize \
python \
python-i3-py \
python-pip \
qrencode \
r \
@ -177,6 +176,7 @@ aur: yay
networkmanager-dmenu-git \
openvpn-update-systemd-resolved \
plantuml \
python-i3ipc \
qutebrowser-git \
rtv \
sc-im \

62
scripts/.config/Scripts/i3-focus

@ -1,62 +0,0 @@
#!/usr/bin/env python3
import i3
from subprocess import check_output
import json
def findWindow(container):
if container['nodes'] == []:
if container['focused'] == True:
return container
else: return None
for con in container['nodes']:
win = findWindow(con)
if win != None: return win
for con in container['floating_nodes']:
win = findWindow(con)
if win != None: return win
def find_tmp(container):
if container['nodes'] == []:
if container['window'] == None and container['name'] == None:
return container['id']
else: return None
for con in container['nodes']:
tmp = find_tmp(con)
if tmp != None: return tmp
def create_tmp(current_id):
i3.focus(con_id=current_id)
i3.split('vertical')
i3.open()
def destroy_tmp(tmp_id):
i3.kill(con_id=tmp_id)
def make_float(current_id):
i3.focus(con_id=current_id)
i3.floating('enable')
i3.resize('set 1500 800')
i3.move('position center')
def make_unfloat(current_id):
i3.focus(con_id=current_id)
i3.floating('disable')
def main():
tree = check_output(['i3-msg', '-t', 'get_tree']).decode('UTF-8').strip()
root = json.loads(tree)
current = findWindow(root)
current_id = current['id']
if "on" in current['floating']:
tmp_id = find_tmp(root)
if tmp_id != None:
i3.focus(con_id=tmp_id)
make_unfloat(current_id)
destroy_tmp(tmp_id)
else:
if find_tmp(root) == None:
create_tmp(current_id)
make_float(current_id)
main()

31
scripts/.config/Scripts/i3-workspaceswap

@ -1,16 +1,27 @@
#!/usr/bin/env python3
import i3
from i3ipc import Connection
import time
# connect to i3
i3 = Connection()
# retrieve only active outputs
outputs = list(filter(lambda output: output['active'], i3.get_outputs()))
workspaces = [o.current_workspace for o in i3.get_outputs() if o.active]
focused = [w.name for w in i3.get_workspaces() if w.focused]
print(workspaces)
if len(workspaces) == 2:
i3.command("workspace " + workspaces[0])
i3.command("move workspace to output right")
# set current workspace to output 0
i3.workspace(outputs[0]['current_workspace'])
time.sleep(0.01)
# ..and move it to the other output.
# outputs wrap, so the right of the right is left ;)
i3.command('move', 'workspace to output right')
i3.command("workspace " + workspaces[1])
i3.command("move workspace to output left")
# rinse and repeat
i3.workspace(outputs[1]['current_workspace'])
i3.command('move', 'workspace to output right')
i3.command("workspace " + focused[0])
elif len(workspaces) < 2:
print("Not enough outputs")
else:
print("Too many outputs")

2
zathura/.config/zathura/zathurarc

@ -7,4 +7,4 @@ set guioptions ''
map i recolor
map p print
include /home/micah/.config/wpg/formats/colors-zathurarc
include /home/micah/.cache/wal/colors-zathurarc
Loading…
Cancel
Save