aboutsummaryrefslogtreecommitdiff
path: root/rofi/workspaces.sh
blob: 8495f8d2cf9198bcef3596ebfef1a99604f26045 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
WORKSPACES=~/.config/i3/workspaces

if [ -z $1 ]; then
  for fic in ~/.config/i3/workspaces/*.json; do 
      echo $(basename "$fic" .json)
  done
  exit 0
else
  WINDOWS=$(xdotool search --all --onlyvisible --desktop $(xprop -notype -root _NET_CURRENT_DESKTOP | cut -c 24-) "" 2>/dev/null)
  # Load the workspace
  i3-msg "workspace $1; append_layout ${WORKSPACES}/${1}.json; workspace back_and_forth" > /dev/null
  # get the list of windows on the current workspace
  for window in $WINDOWS; do
    HAS_PID=$(xdotool getwindowpid $window 2>&1 | grep "pid" | wc -l)
  
    # Unmap the window to make it disapear, then map it again for i3 trigger the swallow
    xdotool windowunmap $window
    xdotool windowmap $window
  done
  i3-msg "workspace $1" > /dev/null
  exit 1
fi