pinwheel: Add module for spotify

This commit is contained in:
Alexander Heldt
2023-09-19 22:08:24 +02:00
parent c771a1d7ed
commit 2c90e636b5
4 changed files with 53 additions and 14 deletions

View File

@@ -27,6 +27,7 @@
./modules/calibre ./modules/calibre
./modules/go ./modules/go
./modules/nix ./modules/nix
./modules/spotify
]; ];
nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.experimental-features = [ "nix-command" "flakes" ];

View File

@@ -15,7 +15,6 @@
home.packages = with pkgs; [ home.packages = with pkgs; [
gnumake gnumake
tig tig
spotify
onlyoffice-bin onlyoffice-bin
qmk qmk
]; ];

View File

@@ -0,0 +1,19 @@
{ pkgs, ... }:
{
home-manager.users.alex = {
home.packages = with pkgs; [
spotify
playerctl
];
wayland.windowManager.hyprland = {
settings = {
bind = [
"$mod ALT, LEFT, exec, ${pkgs.playerctl}/bin/playerctl -p spotify previous"
"$mod ALT, RIGHT, exec, ${pkgs.playerctl}/bin/playerctl -p spotify next"
"$mod ALT, DOWN, exec, ${pkgs.playerctl}/bin/playerctl -p spotify play-pause"
];
};
};
};
}

View File

@@ -1,4 +1,28 @@
{ pkgs, ... }: { pkgs, ... }:
let
spotify-status = pkgs.writeShellScript "spotify-status" ''
STATUS=$(${pkgs.playerctl}/bin/playerctl -p spotify status 2>&1)
if [ "$STATUS" = "No players found" ]; then
echo " "
else
TITLE=$(${pkgs.playerctl}/bin/playerctl -p spotify metadata xesam:title)
ARTIST=$(${pkgs.playerctl}/bin/playerctl -p spotify metadata xesam:artist)
case "$STATUS" in
"Playing")
echo "<span font='14' rise='-3000'></span> $TITLE - $ARTIST"
;;
"Paused")
echo "<span font='14' rise='-3000'></span> $TITLE - $ARTIST"
;;
*)
echo " "
;;
esac
fi
'';
in
{ {
home-manager.users.alex = { home-manager.users.alex = {
programs.waybar = { programs.waybar = {
@@ -16,16 +40,12 @@
]; ];
modules-left = [ "hyprland/workspaces" ]; modules-left = [ "hyprland/workspaces" ];
modules-center = [ "custom/hello" ]; modules-right = [ "custom/spotify" "wireplumber" "battery" "clock" ];
modules-right = [ "tray" "wireplumber" "battery" "clock" ];
"custom/hello" = { "custom/spotify" = {
format = "hello {}"; exec = spotify-status;
max-length = 40; interval = 1;
interval = "once"; tooltip = false;
exec = pkgs.writeShellScript "hello-from-waybar" ''
echo "from within waybar"
'';
}; };
wireplumber = { wireplumber = {
@@ -45,7 +65,8 @@
in in
'' ''
* { * {
margin-right: 2px; font-family: 'DejaVuSansM Nerd Font Mono';
font-size: 20px;
} }
#workspaces button { #workspaces button {
@@ -72,9 +93,8 @@
background-color: ${background}; background-color: ${background};
} }
#custom-hello { #custom-spotify, #wireplumber, #battery, #clock {
color: ${foreground}; margin: 0 12px;
background-color: ${background};
} }
''; '';
}; };