Skip to content

Instantly share code, notes, and snippets.

@IronOxidizer
Last active April 18, 2023 17:03
Show Gist options
  • Save IronOxidizer/f293e9cffd1c350af1995fce9c837ed2 to your computer and use it in GitHub Desktop.
Save IronOxidizer/f293e9cffd1c350af1995fce9c837ed2 to your computer and use it in GitHub Desktop.
def minimize_all_windows():
# create a display object
disp = display.Display()
# get the root window
root = disp.screen().root
# get the atoms for minimizing and for the window list
wm_state = disp.intern_atom('_NET_WM_STATE')
wm_state_hidden = disp.intern_atom('_NET_WM_STATE_HIDDEN')
win_list = disp.intern_atom('_NET_CLIENT_LIST')
# get the list of windows
win_list_raw = root.get_full_property(win_list, 0).value
win_list = [w for w in win_list_raw if w != 0]
# iterate over the windows and minimize them
for w in win_list:
w.change_property(wm_state, 'ATOM', 32, [wm_state_hidden], 0)
# flush the changes to the server
disp.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment