Skip to content

Instantly share code, notes, and snippets.

@LC43
Last active May 14, 2022 00:18
Show Gist options
  • Save LC43/e45eb381e87f5db43279979e7141bc63 to your computer and use it in GitHub Desktop.
Save LC43/e45eb381e87f5db43279979e7141bc63 to your computer and use it in GitHub Desktop.
Send window to previous workspace
#!/bin/bash
## workspace Number ( count )
WS_N=$(wmctrl -d | wc -l)
## workspace ID
WS_ID=$(wmctrl -d | grep '*' | cut -d ' ' -f1)
## previous workspace id ( loops around )
PREV_ID=$(( ( $WS_ID - 1 ) % $WS_N ));
if [ $PREV_ID -lt 0 ]; then PREV_ID=$(( $PREV_ID+ $WS_N )); fi
wmctrl -r :ACTIVE: -t "${PREV_ID}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment