Skip to content

Instantly share code, notes, and snippets.

@platan
Created January 12, 2015 16:10
Show Gist options
  • Save platan/e63b465c2fcfe3d0cccd to your computer and use it in GitHub Desktop.
Save platan/e63b465c2fcfe3d0cccd to your computer and use it in GitHub Desktop.
Maximize all windows from command line in linux (via wmctrl)
#!/bin/bash
window_ids=$(wmctrl -l | cut -f1 -d " ")
for window_id in $window_ids
do
wmctrl -i -r "$window_id" -b add,maximized_vert,maximized_horz
done
@brotherJ4mes
Copy link

This is great!

I modified it slighty with

  1. "toggle" instead of "add" I can switch back and forth
  2. xargsso it could be one-line and then added as a bash alias.
wmctrl -l | awk '{print $1}' | xargs -n1  wmctrl -b toggle,maximized_vert,maximized_horz -i -r

if you want to avoid quotes you can replace the awk section with cut -d\ -f (not two spaces after the backslash)

@brotherJ4mes
Copy link

....on second thought, I'm not sure "toggle" is ideal since it will un-maximize windows that are already maxed. might make two separate aliases instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment