From 6a53771f20c1ada17fe54c941bd8b871ffdb35c8 Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L de Mello" Date: Mon, 10 Feb 2025 18:28:24 -0300 Subject: [PATCH] feat: status bar try --- flake.nix | 1 + home/guz-lite/desktop.nix | 161 ++++++++++++++++++++- home/guz-lite/eww/eww.scss | 43 ++++++ home/guz-lite/eww/eww.yuck | 95 ++++++++++++ home/guz-lite/style.nix | 36 +++++ home/guz-lite/waybar.css | 65 +++++++++ home/guz-lite/waybar_1.css | 272 +++++++++++++++++++++++++++++++++++ home/guz-lite/wayland_1.json | 221 ++++++++++++++++++++++++++++ modules/home-manager/eww.nix | 119 +++++++++++++++ 9 files changed, 1006 insertions(+), 7 deletions(-) create mode 100644 home/guz-lite/eww/eww.scss create mode 100644 home/guz-lite/eww/eww.yuck create mode 100644 home/guz-lite/waybar.css create mode 100644 home/guz-lite/waybar_1.css create mode 100644 home/guz-lite/wayland_1.json create mode 100644 modules/home-manager/eww.nix diff --git a/flake.nix b/flake.nix index 846141f..2f5ff8d 100644 --- a/flake.nix +++ b/flake.nix @@ -111,6 +111,7 @@ homeManagerModules = { devenv = ./modules/home-manager/devenv.nix; zen-browser = ./modules/home-manager/zen-browser.nix; + eww = ./modules/home-manager/eww.nix; }; packages = forAllSystems (pkgs: { diff --git a/home/guz-lite/desktop.nix b/home/guz-lite/desktop.nix index 2f82486..01d5a68 100644 --- a/home/guz-lite/desktop.nix +++ b/home/guz-lite/desktop.nix @@ -2,11 +2,13 @@ config, lib, pkgs, + self, ... -}: { - # Desktop Environment +}: let +in { + imports = [self.homeManagerModules.eww]; - ## Hyprland + # Hyprland wayland.windowManager.hyprland.enable = true; wayland.windowManager.hyprland.xwayland.enable = true; wayland.windowManager.hyprland.settings = { @@ -79,7 +81,7 @@ ]; }; - ### Idle lock screen + ## Idle lock screen programs.hyprlock.enable = true; services.hypridle.enable = true; @@ -102,14 +104,157 @@ }; }; - ### Wallpaper + ## Wallpaper services.hyprpaper.enable = true; - ### File picker and other portals not implemented by XDPH + ## File picker and other portals not implemented by XDPH xdg.portal.extraPortals = with pkgs; [ xdg-desktop-portal-gtk ]; + # Status bar + # programs.eww-custom.enable = true; + # programs.eww-custom.widgets = let + # hyprland-workspaces = lib.getExe pkgs.hyprland-workspaces; + # hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"; + # jq = lib.getExe pkgs.jq; + # awk = lib.getExe' pkgs.gawk "awk"; + # socat = lib.getExe pkgs.socat; + # + # # Currently borked + # eww-active-workspace = pkgs.writeShellScriptBin "eww-active-workspace" '' + # ${hyprctl} monitors -j | + # ${jq} '.[] | select(.focused) | .activeWorkspace.id' + # + # ${socat} -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | + # stdbuf -o0 ${awk} -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}' + # ''; + # + # pulsemixer = lib.getExe pkgs.pulsemixer; + # + # eww-volume = pkgs.writeShellScriptBin "eww-volume" '' + # sink="$(echo $(${pulsemixer} -l | grep 'Default' | grep 'sink-' | awk '{print $3}') | rev | cut -c 2- | rev)" + # + # echo "$(${pulsemixer} --id "$sink" --get-volume | awk '{print $1}')" + # ''; + # in + # '''' + # + (with config.wayland.windowManager.hyprland.settings; '' + # (defvar MONITOR_W "${toString 2560}") + # (defvar GAPS_IN "${toString general.gaps_in}") + # (defvar GAPS_OUT "${toString general.gaps_out}") + # '') + # + (builtins.readFile ./eww/eww.yuck); + # programs.eww-custom.addPath = [ + # pkgs.coreutils + # ]; + # programs.eww-custom.style = + # (with config.wayland.windowManager.hyprland.settings; '' + # $rounding: ${toString decoration.rounding}px; + # $gaps-in: ${toString general.gaps_in}px; + # $gaps-out: ${toString general.gaps_out}px; + # '') + # + (with config.stylix.fonts; '' + # $font-serif: '${serif.name}'; + # $font-sans-serif: '${sansSerif.name}'; + # $font-monospace: '${monospace.name}'; + # $font-emoji: '${emoji.name}'; + # '') + # + (with config.lib.stylix.colors.withHashtag; '' + # $base00: ${base00}; + # $base01: ${base01}; + # $base02: ${base02}; + # $base03: ${base03}; + # $base04: ${base04}; + # $base05: ${base05}; + # $base06: ${base06}; + # $base07: ${base07}; + # $base08: ${base08}; + # $base09: ${base09}; + # $base0A: ${base0A}; + # $base0B: ${base0B}; + # $base0C: ${base0C}; + # $base0D: ${base0D}; + # $base0E: ${base0E}; + # $base0F: ${base0F}; + # '') + # + (builtins.readFile ./eww/eww.scss); + + ## Temp status bar + programs.waybar.enable = true; + programs.waybar.style = builtins.readFile ./waybar.css; + # programs.waybar.settings.single = with builtins; fromJSON (readFile ./wayland.json); + programs.waybar.settings.single = { + layer = "top"; + position = "top"; + height = 25; + spacing = 5; + + margin-top = 5; + margin-right = 10; + margin-left = 10; + + modules-left = [ + "hyprland/workspaces" + ]; + + "hyprland/workspaces" = { + active-only = false; + persistent-workspaces = let + MONITOR-1 = config.wayland.windowManager.hyprland.settings."$MONITOR-1"; + MONITOR-2 = config.wayland.windowManager.hyprland.settings."$MONITOR-2"; + in { + "${MONITOR-1}" = [1 2 3 4 5]; + "${MONITOR-2}" = [6 7 8 9 10]; + }; + format = "{icon}"; + format-icons = { + default = ""; + active = ""; + }; + }; + modules-center = [ + "clock" + ]; + + "clock" = { + format = "{:%R}"; + format-alt = "{:%B %d, 12.0%y (%A)}"; + tooltip-format = "{calendar}"; + calendar = { + mode = "year"; + mode-mon-col = 3; + weeks-pos = "left"; + on-scroll = 1; + format = with config.lib.stylix.colors.withHashtag; { + months = "{}"; + days = "{}"; + weeks = "W{}"; + weeksdays = "{}"; + today = "{}"; + }; + }; + }; + + "hyprland/window" = { + format = "{title}"; + }; + + modules-right = [ + "pulseaudio" + "cpu" + "memory" + "disk" + ]; + + "disk" = { + interval = 30; + format = "{specific_free:0.2f}"; + unit = "GB"; + }; + }; + programs.waybar.systemd.enable = true; + # Notifications services.dunst.enable = true; services.dunst.settings = { @@ -124,5 +269,7 @@ # Clipboard services.cliphist.enable = true; services.cliphist.allowImages = true; - home.packages = with pkgs; [wl-clipboard]; + home.packages = with pkgs; [ + wl-clipboard + ]; } diff --git a/home/guz-lite/eww/eww.scss b/home/guz-lite/eww/eww.scss new file mode 100644 index 0000000..8678ab8 --- /dev/null +++ b/home/guz-lite/eww/eww.scss @@ -0,0 +1,43 @@ +.body { + background-color: red; + border-radius: $rounding; + + font-family: $font-monospace; + font-weight: bold; + color: $base05; + + padding: 0px $gaps-out; +} + +.workspaces { + font-family: $font-emoji; + font-size: 0.7rem; +} + +.day { + padding-left: $gaps-out; +} + +.valuebar { + scale { + min-height: 5px; + } + + scale trough { + all: unset; + background: darkgreen; + border-radius: 50px; + min-height: 5px; + min-width: 50px; + + slider { + all: unset; + } + + highlight { + all: unset; + background: green; + border-radius: 10px; + } + } +} diff --git a/home/guz-lite/eww/eww.yuck b/home/guz-lite/eww/eww.yuck new file mode 100644 index 0000000..5db7476 --- /dev/null +++ b/home/guz-lite/eww/eww.yuck @@ -0,0 +1,95 @@ +(defpoll time :interval "10s" :initial "00:00" `date +%H:%M`) +(defpoll date :interval "1m" :initial "00/00" `date +%d/%m`) +(defpoll week-day :interval "1m" :initial "1" `date +%w`) + +(defvar bar1g (geometry + :x "0%" :y "0%" + :width "2560px" + :height "20px" + :anchor "top center")) + +(defwindow statusbarcomplete + :monitor 0 + :stacking "fg" + :exclusive true + :reserve (struts :distance "20px" :side "top") + :windowtype "dock" + :focusable false + :geometry bar1g + (box + :orientation "h" + :class "topbar-shell" + (centerbox + :orientation "h" + :class "body" + (box + :halign "start" + (day)) + (empty) + (box + :halign "end" + (statuses))))) + + +;; (defwidget workspaces [workspace] +;; (box +;; :class "workspaces" +;; :orientation "h" +;; "${ +;; workspace == 1 ? '' : '' +;; } ${ +;; workspace == 2 ? '' : '' +;; } ${ +;; workspace == 3 ? '' : '' +;; } ${ +;; workspace == 4 ? '' : '' +;; } ${ +;; workspace == 5 ? '' : '' +;; }")) + +(defwidget day [] + (box + :orientation "h" + :class "day" + ; Sun, Moon, Mars, Mercury, Jupiter, Venus, Saturn + "${[" Sun", " Mon", " Tue", "󰬸 Wed", "󱡓 Thu", " Fri", " Sat"][week-day]} ${date} - ${time}")) + +(defwidget statuses [] + (box + :class "statuses" + :orientation "h" + (box + (valuebar + :label "" + :value-text "Ram: ${round(EWW_RAM.used_mem_perc, 2)}% used" + :value "${EWW_RAM.used_mem_perc}")) + (box + (valuebar + :label "" + :value-text "CPU ${round(EWW_CPU.avg, 2)}" + :value "${EWW_CPU.avg}")) + (box + (valuebar + :label "󰨣" + :value-text "Disk: ${round(EWW_DISK["/"].used_perc, 2)}% used" + :value "${EWW_DISK["/"].used_perc}")))) + +(defwidget valuebar [label value ?value-text ?onchange ?onclick] + (box + :class "valuebar" + :orientation "h" + :space-evenly false + :tooltip "${value-text == "" ? value : value-text}" + (box + :orientation "h" + :space-evenly false + :class "label" + label) + (scale + :min 0 + :max 101 + :active {onchange != ""} + :onchange onchange + :value value))) + +(defwidget empty [] "") diff --git a/home/guz-lite/style.nix b/home/guz-lite/style.nix index 83d5098..776d52f 100644 --- a/home/guz-lite/style.nix +++ b/home/guz-lite/style.nix @@ -24,4 +24,40 @@ font: "${config.stylix.fonts.sansSerif.name}"; } ''; + + # Fonts + fonts.fontconfig.enable = true; + fonts.fontconfig.defaultFonts = with config.stylix.fonts; { + sansSerif = [sansSerif.name]; + serif = [serif.name]; + monospace = [monospace.name]; + emoji = [emoji.name]; + }; + stylix.fonts = with pkgs; { + monospace = { + package = nerdfonts.override {fonts = ["FiraCode"];}; + name = "FiraCode Nerd Font"; + }; + }; + home.packages = [ + (pkgs.stdenv.mkDerivation rec { + pname = "calsans"; + version = "1.0.0"; + src = pkgs.fetchzip { + url = "https://github.com/calcom/font/releases/download/v${version}/CalSans_Semibold_v${version}.zip"; + stripRoot = false; + hash = "sha256-JqU64JUgWimJgrKX3XYcml8xsvy//K7O5clNKJRGaTM="; + }; + installPhase = '' + runHook preInstall + install -m444 -Dt $out/share/fonts/truetype fonts/webfonts/*.ttf + runHook postInstall + ''; + meta = with lib; { + homepage = "https://github.com/calcom/font"; + license = licenses.ofl; + platforms = platforms.all; + }; + }) + ]; } diff --git a/home/guz-lite/waybar.css b/home/guz-lite/waybar.css new file mode 100644 index 0000000..0d4e059 --- /dev/null +++ b/home/guz-lite/waybar.css @@ -0,0 +1,65 @@ +* { + border: none; + border-radius: 4px; + /* `ttf-font-awesome` is required to be installed for icons */ + /* font-family: "Roboto Mono Medium", Helvetica, Arial, sans-serif; */ + + /* adjust font-size value to your liking: */ + font-size: 0.7rem; + font-weight: bold; + + min-height: 0; +} + +window#waybar, +tooltip { + background-color: @base01; + /* background-color: red; */ + /* box-shadow: 0px -10px 10px #00000055; */ + box-shadow: 0px -10px 10px #00ff0055; + /* border-bottom: 3px solid rgba(100, 114, 125, 0.5); */ + color: @base05; + /* transition-property: background-color; */ + /* transition-duration: .5s; */ + /* border-radius: 0; */ + padding: 0 10px; +} + +#clock { + background-color: transparent; +} + +.modules-left { + padding-right: 10px; +} + +.modules-left { + padding-left: 10px; +} + +.modules-left #workspaces { + padding: 0; +} + +.modules-left #workspaces button { + padding-left: 0; + padding-right: 0; + + /* Align icons */ + padding-top: 6px; +} + +.modules-left #workspaces button.active { + border-bottom-style: none; + + /* Align icons */ + padding-top: 3px; +} + +#pulseaudio { + background: @base05; + opacity: 1; + margin: 0px 0px 0px 0px; + padding-left: 3px; + padding-right: 3px; +} diff --git a/home/guz-lite/waybar_1.css b/home/guz-lite/waybar_1.css new file mode 100644 index 0000000..3649bec --- /dev/null +++ b/home/guz-lite/waybar_1.css @@ -0,0 +1,272 @@ +/* ================================ */ +/* Common CSS */ +/* ================================ */ +* { + /* `otf-font-awesome` is required to be installed for icons */ + padding: 0; + border-radius: 0; + min-height: 0; + margin: 0; + border: none; + text-shadow: none; + transition: none; + box-shadow: none; +} + +/* the whole window */ +window#waybar { + background: #3c3835; + color: #fff4d2; + padding-right: 9px; + padding-left: 5px; + margin: 0; + border-radius: 19px; +} + +tooltip { + background: rgba(255, 244, 210, 0.8); + color: #3c3835; + border: 2px solid #3c3835; + border-radius: 5px; +} + +.modules-left { + padding-left: 5px; +} + +.modules-right { + padding-right: 5px; +} + +#custom-rofi, +#workspaces button, +#workspaces button:hover, +#workspaces button.visible, +#workspaces button.visible:hover, +#workspaces button.active, +#workspaces button.active:hover, +#workspaces button.urgent, +#window, +#tray, +#disk, +#cpu, +#temperature, +#temperature.critical, +#backlight, +#custom-memory, +#pulseaudio, +#pulseaudio.muted, +#battery, +#battery.critical, +#battery.warning, +#clock { + font-family: JetBrainsMono Nerd Font Propo; + font-size: 14px; + font-weight: 400; + color: #202020; + background: #202020; + border-radius: 2px; +} + +#window, +#tray, +#disk, +#cpu, +#temperature, +#temperature.critical, +#backlight, +#custom-memory, +#pulseaudio, +#pulseaudio.muted, +#battery, +#battery.critical, +#battery.warning, +#clock { + padding-right: 4px; + margin: 5px 0px; +} + +#custom-rofi { + /* border: 2px solid #458588; */ + /* border-radius: 5px; */ + background: #3c3835; + padding: 0 6px; + margin: 5px 0px; +} + +/* ================================ */ +/* workspaces module */ +/* ================================ */ +#workspaces { + margin: 0px; +} + +#workspaces button { + color: #fff4d2; + background: #3c3835; + /* border: 2px solid #fff4d2; */ + min-width: 25px; + padding: 0 4px; + margin: 5px 3px; +} + +#workspaces button:hover { + background: #3c3835; + border: 2px solid #b16286; + border-radius: 12px; +} + +#workspaces button.visible { + border: 2px solid #689d6a; + border-radius: 12px; + background: #3c3835; +} + +#workspaces button.visible:hover { + border: 2px solid #689d6a; + border-radius: 12px; + background: #3c3835; +} + +#workspaces button.active { + border: 2px solid #689d6a; + border-radius: 12px; + background: #3c3835; +} + +#workspaces button.active:hover { + border: 2px solid #689d6a; + border-radius: 12px; + background: #3c3835; +} + +#workspaces button.urgent { + border: 2px solid #cc241d; + border-radius: 12px; + background: #3c3835; +} + +/* ================================ */ +/* window */ +/* ================================ */ + +#window { + color: #a89884; + background: #3c3835; + /* border: 2px solid #d3869b; */ +} + +/* ================================ */ +/* tray */ +/* ================================ */ + +#tray { + /* padding: 0 6px; */ + background: #3c3835; +} + +/* ================================ */ +/* disk */ +/* ================================ */ + +#disk { + color: #ea6962; + border: 2px solid #ea6962; +} + +/* ================================ */ +/* cpu */ +/* ================================ */ +#cpu { + color: #e78a4e; + border: 2px solid #e78a4e; +} + +/* ================================ */ +/* temp */ +/* ================================ */ +#temperature { + color: #d8a657; + border: 2px solid #d8a657; +} + +#temperature.critical { + color: #cc241d; + border: 2px solid #cc241d; +} + +/* ================================ */ +/* backlight */ +/* ================================ */ +#custom-backlight { + color: #f6c657; + background: #3c3835; +} + +/* ================================ */ +/* memory */ +/* ================================ */ +#custom-memory { + color: #458588; + border: 2px solid #458588; +} + +/* ================================ */ +/* pulseaudio */ +/* ================================ */ +#pulseaudio { + color: #fbf1c7; + background: #3c3835; +} + +#pulseaudio.muted { + color: #ea6962; + background: #3c3835; +} + +/* ================================ */ +/* battery */ +/* ================================ */ +#battery { + color: #fbf1c7; + background: #3c3835; +} + +#battery.critical { + color: #cc241d; + background: #3c3835; +} + +#battery.warning { + color: #e78a4e; + background: #3c3835; +} + +/* ================================ */ +/* clock */ +/* ================================ */ +#clock.time { + color: #fbf1c7; + background: #3c3835; +} + +#clock.date { + color: #fbf1c7; + background: #3c3835; +} + +#custom-notification { + color: #fbf1c7; + font-size: 14px; + background: #3c3835; + padding: 2px 2px; +} + +#custom-player { + color: #282828; + border: 2px solid #3c3835; + border-radius: 21px; + background: #fbf1c7; + padding-left: 9px; + padding-right: 9px; +} diff --git a/home/guz-lite/wayland_1.json b/home/guz-lite/wayland_1.json new file mode 100644 index 0000000..a8f7a1c --- /dev/null +++ b/home/guz-lite/wayland_1.json @@ -0,0 +1,221 @@ +{ + "layer": "top", + "position": "top", + "height": 20, + "spacing": 5, + "margin-top": 3, + "margin-right": 3, + "margin-left": 3, + "modules-left": [ + "custom/rofi", + "hyprland/workspaces", + "custom/paddc", + "custom/prefix", + "hyprland/window", + "custom/paddc", + "tray" + ], + "modules-center": [ + "custom/player" + ], + "modules-right": [ + "pulseaudio", + "custom/backlight", + "hyprland/language", + "custom/paddc", + "custom/paddc", + "bluetooth", + "battery", + "custom/paddc", + "custom/notification", + "custom/paddc", + "custom/wifi", + "custom/paddc", + "clock#date", + "custom/paddc", + "clock#time", + "custom/paddc" + ], + "custom/rofi": { + "format": "󰮯", + "on-click": "rofi -show drun", + "on-click-right": "wlogout", + "escape": true, + "tooltip": false + }, + "hyprland/workspaces": { + "disable-scroll": true, + "active-only": false, + "all-outputs": true, + "warp-on-scroll": false, + "format": "{icon}", + "format-icons": { + "1": "󰊠", + "2": "󰊠", + "3": "󰊠", + "4": "󰊠", + "5": "󰊠", + "6": "󰊠", + "7": "󰊠", + "default": "󰊠" + }, + "persistent-workspaces": { + "*": 5 + } + }, + "hyprland/window": { + "format": "{class}", + "max-length": 20, + "rewrite": { + "": " hyprland", + "~": " terminal", + "com.mitchellh.ghostty": "ghostty" + } + }, + "tray": { + "icon-size": 15, + "spacing": 8 + }, + "pulseaudio": { + "format": "{volume}%", + "format-muted": "{volume}%", + "format-bluetooth": " 󰂰 {volume}%", + "format-bluetooth-muted": " 󰂲 {volume}%", + "format-source": "{volume}% ", + "on-click": "pactl set-sink-mute @DEFAULT_SINK@ toggle", + "tooltip": false, + "max-volume": 130 + }, + "battery#bat2": { + "bat": "BAT2" + }, + "battery": { + "interval": 1, + "states": { + "good": 99, + "warning": 30, + "critical": 20 + }, + "format-icons": [ + " ", + " ", + " ", + " ", + " " + ], + "format": " {icon}{capacity}%", + "format-critical": " {icon}{capacity}%", + "format-warning": " {icon}{capacity}%", + "format-full": " {icon}{capacity}%", + "format-charging": "{capacity}%", + "format-charging-warning": "{capacity}%", + "format-charging-critical": "{capacity}%", + "format-plugged": "{capacity}%", + "tooltip": false + }, + "clock#date": { + "format": "󰃭 {:%a %d %b}", + "tooltip-format": "{calendar}", + "calendar": { + "mode": "month", + "mode-mon-col": 6, + "on-click-right": "mode", + "format": { + "months": "{}", + "weekdays": "{}", + "today": "{}" + } + }, + "actions": { + "on-click": "mode", + "on-click-right": "mode" + }, + "min-length": 8, + "max-length": 20 + }, + "clock#time": { + "format": "󱑂 {:%I:%M %p}", + "tooltip": false, + "min-length": 8, + "max-length": 12 + }, + "custom/backlight": { + "exec": "~/.config/waybar/scripts/brightness-control.sh", + "return-type": "json", + "format": "{}", + "tooltip": true, + "on-scroll-up": "~/.config/waybar/scripts/brightness-control.sh -o i", + "on-scroll-down": "~/.config/waybar/scripts/brightness-control.sh -o d", + "interval": 1, + "min-length": 6, + "max-length": 6 + }, + "custom/paddc": { + "format": " ", + "tooltip": false + }, + "custom/prefix": { + "format": " >>", + "tooltip": false + }, + "hyprland/language": { + "format": "{}", + "format-en": "US" + }, + "custom/wifi": { + "exec": "~/.config/waybar/scripts/wifi-status.sh", + "return-type": "json", + "format": "{}", + "tooltip": true, + "on-click": "~/.config/waybar/scripts/wifi-menu.sh", + "interval": 1, + "min-length": 1, + "max-length": 12 + }, + "bluetooth": { + "format": "󰂰 ", + "format-disabled": "󰂲 ", + "format-connected": "󰂱 ", + "format-connected-battery": "󰂱 ", + "tooltip-format": "{num_connections} connected", + "tooltip-format-disabled": "Bluetooth Disabled", + "tooltip-format-connected": "{num_connections} connected\n{device_enumerate}", + "tooltip-format-enumerate-connected": "{device_alias}", + "tooltip-format-enumerate-connected-battery": "{device_alias}: {device_battery_percentage}%", + "on-click": "~/.config/waybar/scripts/bluetooth-menu.sh", + "interval": 1, + "min-length": 1, + "max-length": 10 + }, + "custom/notification": { + "tooltip": false, + "rotate": 0, + "format": "{icon}", + "format-icons": { + "notification": "󱅫 ", + "none": " ", + "dnd-notification": "󰂛 ", + "dnd-none": "󰂛 ", + "inhibited-notification": " ", + "inhibited-none": " ", + "dnd-inhibited-notification": "󰂛 ", + "dnd-inhibited-none": "󰂛 " + }, + "return-type": "json", + "exec-if": "which swaync-client", + "exec": "swaync-client -swb", + "on-click-right": "swaync-client -d -sw", + "on-click": "swaync-client -t -sw", + "escape": true + }, + "custom/player": { + "exec": "~/.config/waybar/scripts/player.sh", + "format": "{}", + "interval": 1, + "max-length": 35, + "tooltip": false, + "on-click-right": "playerctl next", + "on-click-left": "playerctl previous", + "on-click": "playerctl play-pause" + } +} diff --git a/modules/home-manager/eww.nix b/modules/home-manager/eww.nix new file mode 100644 index 0000000..c204ce5 --- /dev/null +++ b/modules/home-manager/eww.nix @@ -0,0 +1,119 @@ +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.programs.eww-custom; + + eww = cfg.package; + ewwBin = lib.getExe eww; + + # https://github.com/fufexan/dotfiles/blob/eww/home/services/eww/default.nix + reloadScript = let + systemctl = lib.getExe' pkgs.systemdUkify "systemctl"; + in + pkgs.writeShellScript "reload_eww" '' + ${systemctl} --user restart "eww" + + readarray -t windows < $(${ewwBin} list-windows) + + for w in "$${windows[@]}"; do + ${systemctl} --user restart "eww-open@$w" + done + ''; +in { + options.programs.eww-custom = with lib; { + enable = mkEnableOption ""; + package = mkOption { + type = with types; package; + default = pkgs.eww; + }; + + widgets = mkOption { + type = with types; either path lines; + }; + style = mkOption { + type = with types; either path lines; + }; + + autoReload = mkOption { + type = with types; bool; + default = true; + }; + addPath = mkOption { + type = with types; listOf package; + default = []; + }; + }; + config = lib.mkIf cfg.enable { + xdg.configFile."eww/eww.yuck" = + ( + if builtins.isPath cfg.widgets + then { + source = cfg.widgets; + } + else { + text = cfg.widgets; + } + ) + // { + onChange = + if cfg.autoReload + then reloadScript.outPath + else ""; + }; + xdg.configFile."eww/eww.scss" = + ( + if builtins.isPath cfg.style + then { + source = cfg.style; + } + else { + text = cfg.style; + } + ) + // { + onChange = + if cfg.autoReload + then reloadScript.outPath + else ""; + }; + + home.packages = [eww]; + + systemd.user.services = { + "eww" = { + Unit = { + PartOf = ["graphical-session.target"]; + }; + Service = { + Type = "exec"; + Environment = "PATH=/run/wrappers/bin:${lib.makeBinPath cfg.addPath}"; + ExecStart = "${ewwBin} daemon --no-daemonize"; + Restart = "on-failure"; + }; + Install = { + WantedBy = ["graphical-session.target"]; + }; + }; + + # https://github.com/Loara/eww-systemd/blob/master/eww-open%40.service + "eww-open@" = { + Unit = { + Requires = ["eww.service"]; + After = ["eww.service"]; + }; + Service = { + Type = "oneshot"; + ExecStart = "${ewwBin} open --no-daemonize \"%i\""; + ExecStop = "${ewwBin} close --no-daemonize \"%i\""; + RemainAfterExit = "yes"; + }; + Install = { + WantedBy = ["graphical-session.target"]; + }; + }; + }; + }; +}