blob: 04218534e2f0087198f0d89507aee5bfd8839d01 (
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
|
{ config, lib, pkgs, ... }:
let
get_spotify_status = pkgs.writeShellScript "get_spotify_status.sh" ''
#!/bin/bash
PARENT_BAR="example"
PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1)
PLAYER="playerctld"
FORMAT="{{ title }} - {{ artist }}"
update_hooks() {
while IFS= read -r id; do
polybar-msg -p "$id" hook spotify-play-pause $2 1>/dev/null 2>&1
done < <(echo "$1")
}
PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null)
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
STATUS=$PLAYERCTL_STATUS
else
STATUS="No player is running"
fi
if [ "$1" == "--status" ]; then
echo "$STATUS"
else
if [ "$STATUS" = "Stopped" ]; then
echo "Music Stopped"
elif [ "$STATUS" = "Paused" ]; then
update_hooks "$PARENT_BAR_PID" 2
playerctl --player=$PLAYER metadata --format "$FORMAT"
elif [ "$STATUS" = "No player is running" ]; then
echo "Music Off"
else
update_hooks "$PARENT_BAR_PID" 1
playerctl --player=$PLAYER metadata --format "$FORMAT"
fi
fi
'';
hidePolybarInFullscreen = pkgs.writeShellScript "hidePolybarInFullscreen.sh" ''
#!/usr/bin/env bash
sleep 1
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
'';
in
{
services = {
xserver = {
enable = true;
windowManager.i3 = {
enable = true;
};
};
displayManager.defaultSession = "none+i3";
};
home = {
};
}
|