summaryrefslogtreecommitdiffstats
path: root/scripts/rofi-workspaces
blob: a93190f9be898dae5b9e2b3b9920945ac42c4f92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

moveto=0
if [[ "$1" == "--move" ]]; then
  moveto=1
  shift
fi

function get_workspaces () {
  workspace_json="$(i3-msg -t get_workspaces)"
  IFS=','
  read -ra split <<< "$workspace_json"

  for entry in "${split[@]}"; do
    if [[ "$entry" == *"name"* ]]; then
      IFS='"'
      read -ra split <<< "$entry"
      echo "${split[3]}"
    fi
  done
}

selection=$(echo "$(get_workspaces)" | rofi -dmenu "$@")
if [[ $moveto -eq 0 ]]; then
  i3-msg workspace "$selection"
else
  i3-msg move container to workspace "$selection"
fi

# vim: expandtab sw=2 ts=2