From 190b82526a53d94ad491b32d0341b477e1fa5bdc Mon Sep 17 00:00:00 2001 From: Kopatz <7265381+Kropatz@users.noreply.github.com> Date: Fri, 19 Jul 2024 19:45:32 +0200 Subject: [PATCH] add current playing music to polybar --- .config/i3/config | 8 +++++--- .config/polybar/player-mpris-simple.sh | 12 ++++++++++++ home-manager/i3.nix | 17 +++++++++++++---- home-manager/nixvim/git.nix | 24 +++++++++++------------- modules/graphical/i3.nix | 1 + 5 files changed, 42 insertions(+), 20 deletions(-) create mode 100755 .config/polybar/player-mpris-simple.sh diff --git a/.config/i3/config b/.config/i3/config index 0814052..5cb0a0e 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -33,7 +33,9 @@ tiling_drag modifier titlebar # start a terminal bindsym $mod+q exec kitty bindsym $mod+e exec thunar -bindsym Print exec --no-startup-id maim --select | xclip -selection clipboard -t image/png +#bindsym Print exec --no-startup-id maim --select | xclip -selection clipboard -t image/png + +bindsym Print exec --no-startup-id flameshot gui # kill focused window bindsym $mod+c kill # lock with wallpaper @@ -270,8 +272,8 @@ exec --no-startup-id nm-applet # set lock timeout to 20 minutes exec_always --no-startup-id xset dpms 0 0 1200 & exec --no-startup-id xss-lock --transfer-sleep-lock -- ~/.config/i3/scripts/lock.sh -# prevent screen locking -exec --no-startup-id caffeine +# prevent screen locking, has xdg autostart +# exec --no-startup-id caffeine # NetworkManager is the most popular way to manage wireless networks on Linux, diff --git a/.config/polybar/player-mpris-simple.sh b/.config/polybar/player-mpris-simple.sh new file mode 100755 index 0000000..59419b7 --- /dev/null +++ b/.config/polybar/player-mpris-simple.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# hack nerd font required for icons + +player_status=$(playerctl status 2> /dev/null) + +if [ "$player_status" = "Playing" ]; then + echo " $(playerctl metadata artist) - $(playerctl metadata title)" +elif [ "$player_status" = "Paused" ]; then + echo " $(playerctl metadata artist) - $(playerctl metadata title)" +else + echo "" # nothing is playing +fi diff --git a/home-manager/i3.nix b/home-manager/i3.nix index 032be6c..cf70a9e 100644 --- a/home-manager/i3.nix +++ b/home-manager/i3.nix @@ -43,7 +43,8 @@ in { line-size = "3pt"; font-0 = "Noto Sans:size=11;1"; font-1 = "Hack-Regular.ttf: Hack:style=Regular"; - font-2 = "Noto Sans CJK JP:style=Regular"; + font-2 = "HackNerdFont-Regular.ttf: Hack Nerd Font:style=Regular"; + font-3 = "Noto Sans CJK JP:style=Regular"; border-top-size = 0; border-right-size = 0; border-left-size = 0; @@ -52,10 +53,10 @@ in { padding-left = 2; padding-right = 2; module-margin = 1; - modules-left = "i3"; - modules-center = "xwindow"; + modules-left = "i3 xwindow"; + modules-center = ""; modules-right = - "network memory cpu cpu-temp gpu pulseaudio date tray"; + "music network memory cpu cpu-temp gpu pulseaudio date tray"; cursor-click = "pointer"; cursor-scroll = "ns-resize"; enable-ipc = true; @@ -187,6 +188,14 @@ in { exec = "~/.config/polybar/nvidia.sh"; interval = 3; }; + "module/music" = { + type = "custom/script"; + exec = "~/.config/polybar/player-mpris-simple.sh"; + interval = 3; + "click-left" = "playerctl previous &"; + "click-right" = "playerctl next &"; + "click-middle" = "playerctl play-pause &"; + }; # "network-base" = { # type = "internal/network"; # interval = 5; diff --git a/home-manager/nixvim/git.nix b/home-manager/nixvim/git.nix index d97f432..cf92776 100644 --- a/home-manager/nixvim/git.nix +++ b/home-manager/nixvim/git.nix @@ -1,18 +1,16 @@ { - plugins.diffview = { - enable = true; - }; - plugins.neogit = { - enable = true; - integrations = { - diffview = true; + plugins = { + diffview = { enable = true; }; + neogit = { + enable = true; + integrations = { diffview = true; }; }; - }; - plugins.gitsigns = { - enable = true; - settings = { - current_line_blame = true; - trouble = true; + gitsigns = { + enable = true; + settings = { + current_line_blame = true; + trouble = true; + }; }; }; } diff --git a/modules/graphical/i3.nix b/modules/graphical/i3.nix index dbd5759..172b01f 100644 --- a/modules/graphical/i3.nix +++ b/modules/graphical/i3.nix @@ -75,6 +75,7 @@ in { brightnessctl i3blocks autotiling + flameshot pmutils # suspend with pm-suspend lm_sensors # for cpu in polybar feh # sets the wallpaper