diff options
| author | Caroline Larimore <caroline@larimo.re> | 2024-05-11 18:17:18 -0700 |
|---|---|---|
| committer | Caroline Larimore <caroline@larimo.re> | 2024-05-11 18:17:18 -0700 |
| commit | 27f0c1298f8278bea690b8f5c0dde7bdcf833f2f (patch) | |
| tree | 5911a1509b3c7cdd2ffba5078a90cf3e16828f23 | |
| parent | d0d01097a92c1211eeeac95bc79b3571167a738f (diff) | |
Add EWW music widget
| -rw-r--r-- | home.nix | 12 | ||||
| -rw-r--r-- | modules/home/eww.nix | 148 | ||||
| -rw-r--r-- | modules/home/i3.nix | 3 |
3 files changed, 161 insertions, 2 deletions
@@ -51,8 +51,6 @@ ".local/share/Anki2" ".local/share/lutris" ".local/share/PrismLauncher" - - ".config/eww" ]; files = [ ".Xresources" @@ -75,6 +73,16 @@ home.packages = with pkgs; [ eww + (writeShellScriptBin "eww-toggle"'' + #!/usr/bin/env bash + + if ${pkgs.eww}/bin/eww active-windows | grep $1; then + ${pkgs.eww}/bin/eww close $1 + else + ${pkgs.eww}/bin/eww open $1 + fi + '') + pfetch kdePackages.breeze diff --git a/modules/home/eww.nix b/modules/home/eww.nix index 0b57f06..566eaea 100644 --- a/modules/home/eww.nix +++ b/modules/home/eww.nix @@ -39,4 +39,152 @@ @define-color orange #${c.orange}; @define-color brightOrange #${c.brightOrange}; ''; + + xdg.configFile."eww/eww.css".text = '' + @import "colors.css"; + + window { + color: @fg; + background-color: @bg; + } + + .main { + margin: 8px; + } + + .left { + margin-top: 8px; + } + + .song-title { + font-size: 16px; + font-weight: bold; + } + + .song-album { + color: @fg2; + } + + .song-artist { + color: @fg2; + } + + .control { + font-size: 24; + } + + button { + color: @fg; + background: @bg; + + border: none; + border-radius: 0; + box-shadow: none; + text-shadow: none; + } + + button:hover { + background: @bg1; + } + + button:active { + background: @bg2; + } + ''; + + xdg.configFile."eww/eww.yuck".text = '' + (defwindow music + :monitor 0 + :geometry (geometry + :x "0px" + :y "0px" + :height {128 + 16} + :anchor "bottom center" + ) + :stacking "fg" + :windowtype "dock" + :wm-ignore true + + (box :class "main" + :orientation "h" + :spacing 8 + :space-evenly false + :height {128 + 16} + + (image + :path { substring(song-cover, 7, 255) } + :image-width 128 + :image-height 128 + ) + + (box :class "left" + :orientation "v" + :spacing 0 + :space-evenly true + :hexpand true + + (box :class "info" + :orientation "v" + :space-evenly false + :valign "center" + + (label :class "song-title" + :text song-title + :halign "start" + ) + (label :class "song-album" + :text song-album + :halign "start" + ) + (label :class "song-artist" + :text song-artist + :halign "start" + ) + ) + + (box :class "control" + :space-evenly false + :halign "center" + :valign "end" + + (button + :onclick `playerctl previous` + "" + ) + (button + :onclick `playerctl play-pause` + { song-status == "Playing" ? "" : "" } + ) + (button + :onclick `playerctl next` + "" + ) + + ; Offset controls to center of screen + (box :width {128 + 8}) + ) + ) + ) + ) + + (deflisten song-title + `playerctl -F metadata title` + ) + + (deflisten song-album + `playerctl -F metadata album` + ) + + (deflisten song-artist + `playerctl -F metadata artist` + ) + + (deflisten song-cover + `playerctl -F metadata mpris:artUrl` + ) + + (deflisten song-status + `playerctl -F status` + ) + ''; } diff --git a/modules/home/i3.nix b/modules/home/i3.nix index 151bbaa..3295fc7 100644 --- a/modules/home/i3.nix +++ b/modules/home/i3.nix @@ -128,6 +128,9 @@ "XF86AudioNext" = "exec playerctl next"; "XF86AudioPrev" = "exec playerctl previous"; + # Media controller widget + "${mod}+m" = "exec --no-startup-id eww-toggle music"; + # Workspaces "${mod}+grave" = "workspace number ${ws0}"; "${mod}+1" = "workspace number ${ws1}"; |