Skip to content

Instantly share code, notes, and snippets.

@layus
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save layus/89a6bb8feebe6c1f96d2 to your computer and use it in GitHub Desktop.

Select an option

Save layus/89a6bb8feebe6c1f96d2 to your computer and use it in GitHub Desktop.
Autorandr postswitch hook
#!/bin/bash -x
config="$1"
primary="eDP1"
secondary="eDP1"
case "$config" in
docked)
primary="DP1-1"
secondary="eDP1"
;;
presentation)
secondary="DP1-3"
;;
esac
move_workspace () {
workspace="$1"
output="$2"
sed -i "/^workspace $workspace output/ c \\workspace $workspace output $output" $HOME/.i3/config
# is this needed ? yes !
i3-msg workspace "$workspace"
i3-msg move workspace to output "$output"
i3-msg workspace 1
}
export -f move_workspace
# worspace 0 is on secondary screen
move_workspace 0 "$secondary"
# all other workspaces are on the primary display
# this is just a 'for i in 1 2 ... 10' loop ;)
parallel -kj1 move_workspace "{}" "$primary" ::: $(seq 1 10)
# got to sane default after moving everything
i3-msg workspace 1
# Is reload sufficient to remap workspaces ? Yes
# ! Neither reload nor restart do change the worspace location.
# ! Reload does not create missing (i3)bars.
#i3-msg reload
i3-msg restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment