summaryrefslogtreecommitdiff
path: root/quickshell/gruvbar/scripts/action.sh
blob: 80d26d33d12f9ed8ab83ebb7679d4f5b4eb0409d (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
set -euo pipefail

action="${1:-}"
arg="${2:-}"
polybar_scripts="/home/aag/.config/polybar/scripts"

run_existing() {
  local script="$1"
  shift

  if [ -x "$polybar_scripts/$script" ]; then
    exec "$polybar_scripts/$script" "$@"
  fi
}

case "$action" in
  awake)
    run_existing awake-toggle.sh "$arg"
    ;;
  clipboard)
    run_existing clipboard-menu.sh
    ;;
  display)
    run_existing display-toggle.sh
    ;;
  display-brightness)
    run_existing display-brightness.sh "${arg:-up}"
    ;;
  dunst)
    command -v dunstctl >/dev/null 2>&1 || exit 0
    case "$arg" in
      history) dunstctl history-pop ;;
      close) dunstctl close-all ;;
      *) dunstctl set-paused toggle ;;
    esac
    ;;
  keyboard)
    run_existing kb-switch.sh
    ;;
  mic)
    run_existing mic-toggle.sh
    ;;
  music)
    command -v playerctl >/dev/null 2>&1 || exit 0
    case "$arg" in
      prev) playerctl previous ;;
      next) playerctl next ;;
      *) playerctl play-pause ;;
    esac
    ;;
  power)
    run_existing power-menu.sh
    ;;
  screenshot)
    run_existing screenshot-menu.sh
    ;;
  scratch)
    command -v i3-msg >/dev/null 2>&1 || exit 0
    case "$arg" in
      move) i3-msg move scratchpad ;;
      *) i3-msg scratchpad show ;;
    esac
    ;;
  updates)
    run_existing updates-action.sh
    ;;
  volume)
    command -v pactl >/dev/null 2>&1 || {
      [ "$arg" = "" ] && command -v pavucontrol >/dev/null 2>&1 && exec pavucontrol
      exit 0
    }
    case "$arg" in
      up) pactl set-sink-volume @DEFAULT_SINK@ +5% ;;
      down) pactl set-sink-volume @DEFAULT_SINK@ -5% ;;
      mute) pactl set-sink-mute @DEFAULT_SINK@ toggle ;;
      *) command -v pavucontrol >/dev/null 2>&1 && pavucontrol ;;
    esac
    ;;
  wg)
    run_existing wg-pc-toggle.sh "$arg"
    ;;
esac