Skip to content

Instantly share code, notes, and snippets.

@pablotrianda
Last active October 31, 2023 15:10
Show Gist options
  • Save pablotrianda/293ed1b68e4cd4dc2c47d6f56be6c7f0 to your computer and use it in GitHub Desktop.
Save pablotrianda/293ed1b68e4cd4dc2c47d6f56be6c7f0 to your computer and use it in GitHub Desktop.
Select and change all workspaces to specific monitor
#!/bin/bash
# Script to change all the workspaces to the selected monitor
#
# Requirements:
# [Rofi](https://github.com/davatorium/rofi)
# [jq](https://jqlang.github.io/jq/)
display=$(echo -e "$(xrandr --listmonitors | awk 'NR > 1 {print $NF}')" | rofi -theme Pop-Dark -dmenu -multi-select )
if [ -z "$display" ]; then
exit 0
fi
workspaces=$(i3-msg -t get_workspaces | jq '.[].num' | sort )
for workspace in $workspaces
do
i3-msg workspace $workspace
i3-msg move workspace to output $display
done
# Set the focus to the workspace 1
i3-msg workspace 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment