summaryrefslogtreecommitdiff
path: root/modules/home/i3wm/original/scripts.nix
blob: 4eb0b614e728d0c95d9454dce9ab11585a9db3d1 (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
{ pkgs, ... }:

{
  home.packages = [
    (pkgs.writeShellScriptBin "get-spotify-status" ''
      PARENT_BAR="example"
      PLAYER="playerctld"
      FORMAT="{{ title }} - {{ artist }}"

      PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)

      if [ "$PLAYERCTL_STATUS" = "Playing" ]; then
        playerctl --player=$PLAYER metadata --format "$FORMAT"
      elif [ "$PLAYERCTL_STATUS" = "Paused" ]; then
        echo "Paused"
      else
        echo "No music"
      fi
    '')

    (pkgs.writeShellScriptBin "polybar-hide-on-fullscreen" ''
      i3-msg -t subscribe -m '[ "window" ]' | while read -r event; do
        if echo "$event" | grep -q '"fullscreen_mode":[[:space:]]*1'; then
          polybar-msg cmd hide
        elif echo "$event" | grep -q '"fullscreen_mode":[[:space:]]*0'; then
          polybar-msg cmd show
        fi
      done
    '')
  ];
}