summaryrefslogtreecommitdiffstats
path: root/bin/gaps
diff options
context:
space:
mode:
authorChristian Krinitsin <code@krinitsin.xyz>2024-06-04 22:00:30 +0200
committerChristian Krinitsin <code@krinitsin.xyz>2024-06-04 22:00:30 +0200
commitf470ff39e653eea2ea17d8dcc8c9c1bf1185a4ff (patch)
treef916c30d92c9654efe4b73bdca92770510287097 /bin/gaps
parent0bf547ad73c360b8e86c7e632735cdd926b38cb4 (diff)
parent2dc33f72ec5ffacfc48ba301c3c2d5de8f2c6b89 (diff)
downloaddotfiles-f470ff39e653eea2ea17d8dcc8c9c1bf1185a4ff.tar.gz
dotfiles-f470ff39e653eea2ea17d8dcc8c9c1bf1185a4ff.zip
Merge branch 'main' of github.com:ckrinitsin/dotfiles
Diffstat (limited to 'bin/gaps')
-rwxr-xr-xbin/gaps60
1 files changed, 60 insertions, 0 deletions
diff --git a/bin/gaps b/bin/gaps
new file mode 100755
index 0000000..10ac7a2
--- /dev/null
+++ b/bin/gaps
@@ -0,0 +1,60 @@
+#!/usr/bin/python3
+
+#
+# Interactive gaps, depending on number of applications on a workspace
+#
+
+import i3ipc
+i3 = i3ipc.Connection()
+print("starting")
+
+#################### -- window management -- ####################
+def two_gap():
+ i3.command('gaps left current set 200')
+ i3.command('gaps right current set 200')
+
+def one_gap():
+ i3.command('gaps right current set 400')
+ i3.command('gaps left current set 400')
+
+def remove_gaps():
+ i3.command('gaps left current set 0')
+ i3.command('gaps right current set 0')
+
+def make_window_normal(workspace):
+ i3.command('fullscreen disable')
+
+def make_window_fullscreen(workspace):
+ i3.command('fullscreen enable')
+
+def manage_new_close_window(self, e):
+ focused = i3.get_tree().find_focused()
+ workspace = focused.workspace()
+ monitor = workspace.ipc_data['output']
+
+ if monitor != "HDMI-A-1":
+ return
+
+ y = len(workspace.nodes)
+
+ if y > 2:
+ remove_gaps()
+ return
+
+ if y == 2:
+ two_gap()
+ return
+
+ one_gap()
+ return
+########################### -- end -- ###########################
+
+
+i3.on('window::new', manage_new_close_window)
+i3.on('window::close', manage_new_close_window)
+i3.on('window::move', manage_new_close_window)
+i3.on('window::focus', manage_new_close_window)
+i3.on('workspace::empty', manage_new_close_window)
+i3.on('workspace::init', manage_new_close_window)
+
+i3.main()