Skip to content

Instantly share code, notes, and snippets.

@Hammer2900
Forked from ericbrandwein/i3-smarttitles.py
Created May 26, 2022 14:24
Show Gist options
  • Save Hammer2900/92dad6c7931591e85ec0178712af79d7 to your computer and use it in GitHub Desktop.
Save Hammer2900/92dad6c7931591e85ec0178712af79d7 to your computer and use it in GitHub Desktop.
Hide or show titles in i3wm windows depending on if the Workspace has more than one window. Requires [i3ipc-python](https://github.com/acrisci/i3ipc-python) to be installed.
#!/usr/bin/env python
import i3ipc
# Create the Connection object that can be used to send commands and subscribe
# to events.
i3 = i3ipc.Connection()
def change_titles(windows):
if len(windows) > 1:
command = 'border normal'
else:
command = 'border pixel 1'
for window in windows:
window.command(command)
def on_window(self, e):
focused = i3.get_tree().find_focused()
change_titles(focused.workspace().leaves())
# Subscribe to events
i3.on('window', on_window)
# Start the main loop and wait for events to come in.
i3.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment