diff options
Diffstat (limited to 'enviroments/i3wm.nix')
| -rw-r--r-- | enviroments/i3wm.nix | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/enviroments/i3wm.nix b/enviroments/i3wm.nix new file mode 100644 index 0000000..0421853 --- /dev/null +++ b/enviroments/i3wm.nix @@ -0,0 +1,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 = { + + }; + +}
\ No newline at end of file |
