From ccdf0c289a9c555adb7096fd744223edfdd494e1 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Tue, 30 Jun 2026 00:12:14 +0200 Subject: [PATCH] there is now osd in waybar Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- home/system/hyprland/bindings.nix | 14 +-- home/system/rofi/default.nix | 136 ------------------------------ home/system/swaync/default.nix | 9 +- home/system/swayosd/default.nix | 4 +- home/system/tofi/default.nix | 45 ++++++++++ home/system/waybar/default.nix | 75 +++++++++++++++- home/system/waybar/settings.nix | 14 ++- home/system/waybar/style.nix | 8 +- hosts/laptop/home.nix | 2 +- themes/nixy.nix | 1 + todo | 3 +- 11 files changed, 156 insertions(+), 155 deletions(-) delete mode 100644 home/system/rofi/default.nix create mode 100644 home/system/tofi/default.nix diff --git a/home/system/hyprland/bindings.nix b/home/system/hyprland/bindings.nix index 5c26b26..81beb61 100644 --- a/home/system/hyprland/bindings.nix +++ b/home/system/hyprland/bindings.nix @@ -126,7 +126,7 @@ in { # Quick launch "$mod,RETURN, exec, uwsm app -- ${pkgs.ghostty}/bin/ghostty" # Ghostty (terminal) "$mod,E, exec, uwsm app -- ${pkgs-stable.thunar}/bin/thunar" # Thunar - "$mod, SPACE, exec, rofi -show drun" # Launcher + "$mod, SPACE, exec, tofi-drun" # Launcher "$mod, N, exec, swaync-client -t" # Notification center # Windows @@ -168,8 +168,8 @@ in { bindl = [ # Brightness - ", XF86MonBrightnessUp, exec, swayosd-client --brightness raise" - ", XF86MonBrightnessDown, exec, swayosd-client --brightness lower" + ", XF86MonBrightnessUp, exec, bright-up" + ", XF86MonBrightnessDown, exec, bright-down" # Media ", XF86AudioPlay, exec, playerctl play-pause" @@ -179,10 +179,10 @@ in { ", XF86AudioStop, exec, playerctl stop" # Sound - ", XF86AudioMute, exec, swayosd-client --output-volume mute-toggle" - ", XF86AudioRaiseVolume, exec, swayosd-client --output-volume raise" - ", XF86AudioLowerVolume, exec, swayosd-client --output-volume lower" - ", XF86AudioMicMute, exec, swayosd-client --input-volume mute-toggle" + ", XF86AudioMute, exec, vol-mute" + ", XF86AudioRaiseVolume, exec, vol-up" + ", XF86AudioLowerVolume, exec, vol-down" + ", XF86AudioMicMute, exec, mic-mute" ]; }; } diff --git a/home/system/rofi/default.nix b/home/system/rofi/default.nix deleted file mode 100644 index 6b27a46..0000000 --- a/home/system/rofi/default.nix +++ /dev/null @@ -1,136 +0,0 @@ -{ config, pkgs, ... }: let - c = config.lib.stylix.colors; - font = config.stylix.fonts.sansSerif.name; - fontSize = toString config.stylix.fonts.sizes.applications; - gaps = toString config.theme.gaps-out; - theme = pkgs.writeText "launcher.rasi" '' - configuration { - modi: "drun,run"; - case-sensitive: false; - cycle: true; - normalize-match: true; - show-icons: false; - matching: "normal"; - tokenize: true; - kb-cancel: "Escape,MousePrimary"; - drun-match-fields: "name,exec,generic,comment"; - drun-display-format: "{name}"; - drun-url-launcher: "xdg-open"; - drun-show-actions: false; - disable-history: false; - sorting-method: "normal"; - terminal: "ghostty"; - hover-select: true; - me-select-entry: ""; - me-accept-entry: [ "MousePrimary" ]; - } - - * { - background: transparent; - background-alt: #${c.base01}ff; - foreground: #${c.base05}ff; - active: #${c.base0D}ff; - inactive: #${c.base03}ff; - selected-fg: #${c.base00}ff; - font: "${font}, Bold ${fontSize}"; - } - - window { - transparency: "real"; - location: north; - anchor: north; - padding: ${gaps}px ${gaps}px 0; - margin: 0; - width: 100%; - background-color: transparent; - border: 0px; - } - - mainbox { - orientation: horizontal; - spacing: 0; - padding: 6px 14px; - border-radius: 100px; - background-color: @background-alt; - children: [ "inputbar", "listview" ]; - } - - inputbar { - expand: false; - spacing: 8px; - padding: 0; - background-color: transparent; - color: @foreground; - children: [ "prompt", "entry" ]; - } - - prompt { - background-color: transparent; - color: @active; - padding: 0 2px 0 0; - vertical-align: 0.5; - } - - entry { - background-color: transparent; - color: inherit; - placeholder-color: @inactive; - placeholder: "Search..."; - vertical-align: 0.5; - width: 180px; - } - - listview { - layout: horizontal; - lines: 1; - dynamic: true; - scrollbar: false; - spacing: 0; - padding: 0 0 0 14px; - background-color: transparent; - color: @foreground; - } - - element { - enabled: true; - spacing: 0; - padding: 2px 10px; - border-radius: 100px; - background-color: transparent; - color: @foreground; - cursor: pointer; - children: [ "element-text" ]; - } - - element selected.normal { - background-color: @active; - color: @selected-fg; - } - - element-text { - background-color: transparent; - color: inherit; - vertical-align: 0.5; - } - - message { - padding: 0; - background-color: transparent; - color: @foreground; - } - - error-message { - padding: 10px; - border-radius: 100px; - background-color: @background-alt; - color: @foreground; - } - ''; -in { - stylix.targets.rofi.enable = false; - - programs.rofi = { - enable = true; - theme = "${theme}"; - }; -} diff --git a/home/system/swaync/default.nix b/home/system/swaync/default.nix index ef441c2..2c2969a 100644 --- a/home/system/swaync/default.nix +++ b/home/system/swaync/default.nix @@ -21,6 +21,9 @@ in { positionY = "top"; cssPriority = "user"; "control-center-width" = 450; + "control-center-margin-top" = 0; + "control-center-margin-bottom" = 0; + "control-center-margin-right" = 0; "fit-to-screen" = true; "notification-window-width" = 400; "notification-icon-size" = 40; @@ -189,9 +192,9 @@ in { .control-center { background: @center-bg; - border-radius: var(--border-radius); - border: ${toString border-size}px solid @selected; - margin: 5px; + border-radius: 0 0 0 var(--border-radius); + border-left: ${toString border-size}px solid @selected; + margin: 0; padding: 5px 5px 0 5px; } diff --git a/home/system/swayosd/default.nix b/home/system/swayosd/default.nix index 7285498..b4a4b17 100644 --- a/home/system/swayosd/default.nix +++ b/home/system/swayosd/default.nix @@ -61,8 +61,8 @@ ''; in { services.swayosd = { - enable = true; + enable = false; stylePath = style; - topMargin = 0.5; + topMargin = 0.06; }; } diff --git a/home/system/tofi/default.nix b/home/system/tofi/default.nix new file mode 100644 index 0000000..9e239c8 --- /dev/null +++ b/home/system/tofi/default.nix @@ -0,0 +1,45 @@ +{ + config, + lib, + ... +}: let + c = config.lib.stylix.colors; + font = config.stylix.fonts.serif.name; + gaps = config.theme.gaps-out; + barHeight = config.theme.bar-height; + rounding = + if config.theme.rounding > barHeight / 2 + then barHeight / 2 + else config.theme.rounding; +in { + programs.tofi = { + enable = true; + settings = { + anchor = "top"; + height = barHeight; + margin-top = gaps; + margin-left = 350; + margin-right = 350; + + horizontal = true; + num-results = 8; + result-spacing = 20; + padding-top = 2; + padding-bottom = 2; + padding-left = 14; + padding-right = 14; + + font = lib.mkForce font; + prompt-color = lib.mkForce "#${c.base0D}ff"; + + outline-width = 0; + border-width = 0; + corner-radius = rounding; + + prompt-text = " "; + placeholder-text = "Search..."; + + drun-launch = true; + }; + }; +} diff --git a/home/system/waybar/default.nix b/home/system/waybar/default.nix index 73eeab5..34e3e5d 100644 --- a/home/system/waybar/default.nix +++ b/home/system/waybar/default.nix @@ -15,6 +15,79 @@ done printf '{"text": "󰤭", "class": "disconnected", "tooltip": "Disconnected"}\n' ''; + + updateOsd = '' + [ -f /tmp/waybar-osd-pid ] && kill "$(cat /tmp/waybar-osd-pid)" 2>/dev/null + printf '%s' "$OSD_TEXT" > /tmp/waybar-osd + pkill -RTMIN+8 waybar 2>/dev/null + ( sleep 2.5; rm -f /tmp/waybar-osd /tmp/waybar-osd-pid; pkill -RTMIN+8 waybar 2>/dev/null ) & + printf '%s' "$!" > /tmp/waybar-osd-pid + ''; + + volGetText = '' + VOL_RAW=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_SINK@) + VOL=$(printf '%s' "$VOL_RAW" | awk '{printf "%d", $2*100}') + if printf '%s' "$VOL_RAW" | grep -q MUTED; then + OSD_TEXT="󰝟 $VOL%" + elif [ "$VOL" -lt 33 ]; then + OSD_TEXT="󰕿 $VOL%" + elif [ "$VOL" -lt 66 ]; then + OSD_TEXT="󰖀 $VOL%" + else + OSD_TEXT="󰕾 $VOL%" + fi + ''; + + brightGetText = '' + BRIGHT=$(${pkgs.brightnessctl}/bin/brightnessctl -m | awk -F, '{print int($5)}') + if [ "$BRIGHT" -lt 33 ]; then + OSD_TEXT="󰃞 $BRIGHT%" + elif [ "$BRIGHT" -lt 66 ]; then + OSD_TEXT="󰃟 $BRIGHT%" + else + OSD_TEXT="󰃠 $BRIGHT%" + fi + ''; + + vol-up = pkgs.writeShellScriptBin "vol-up" '' + ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_SINK@ 5%+ --limit 1.0 + ${volGetText} + ${updateOsd} + ''; + + vol-down = pkgs.writeShellScriptBin "vol-down" '' + ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_SINK@ 5%- + ${volGetText} + ${updateOsd} + ''; + + vol-mute = pkgs.writeShellScriptBin "vol-mute" '' + ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SINK@ toggle + ${volGetText} + ${updateOsd} + ''; + + mic-mute = pkgs.writeShellScriptBin "mic-mute" '' + ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SOURCE@ toggle + if ${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_SOURCE@ | grep -q MUTED; then + OSD_TEXT="󰍭 Muted" + else + OSD_TEXT="󰍬 Live" + fi + ${updateOsd} + ''; + + bright-up = pkgs.writeShellScriptBin "bright-up" '' + ${pkgs.brightnessctl}/bin/brightnessctl set 5%+ + ${brightGetText} + ${updateOsd} + ''; + + bright-down = pkgs.writeShellScriptBin "bright-down" '' + ${pkgs.brightnessctl}/bin/brightnessctl set 5%- + ${brightGetText} + ${updateOsd} + ''; in { imports = [ ./settings.nix @@ -31,7 +104,7 @@ in { pavucontrol blueman iw - ]; + ] ++ [vol-up vol-down vol-mute mic-mute bright-up bright-down]; wayland.windowManager.hyprland.settings.exec-once = [ "waybar" diff --git a/home/system/waybar/settings.nix b/home/system/waybar/settings.nix index 318f743..a21238c 100644 --- a/home/system/waybar/settings.nix +++ b/home/system/waybar/settings.nix @@ -6,9 +6,9 @@ in { { layer = "top"; position = "top"; - height = 25; + height = config.theme.bar-height; margin = "${toString gaps-out} ${toString gaps-out} 0"; - modules-center = ["clock" "tray" "hyprland/workspaces" "custom/network" "bluetooth" "battery" "group/right-hidden"]; + modules-center = ["custom/osd" "clock" "tray" "hyprland/workspaces" "custom/network" "bluetooth" "battery" "group/right-hidden"]; "group/right-hidden" = { orientation = "horizontal"; @@ -92,13 +92,21 @@ in { on-click-right = "blueman-manager &"; }; + "custom/osd" = { + exec = "cat /tmp/waybar-osd"; + exec-if = "test -f /tmp/waybar-osd"; + signal = 8; + interval = "once"; + format = "{}"; + }; + pulseaudio = { format = "{icon}"; format-bluetooth = "{icon}"; tooltip-format = "{volume}%"; format-muted = "󰝟"; scroll-step = 2; - on-click = "swayosd-client --output-volume mute-toggle"; + on-click = "vol-mute"; on-click-right = "pavucontrol -t 4 &"; format-icons = { headphone = ""; diff --git a/home/system/waybar/style.nix b/home/system/waybar/style.nix index 7abf5c0..7d2e3c8 100644 --- a/home/system/waybar/style.nix +++ b/home/system/waybar/style.nix @@ -36,7 +36,7 @@ in { background: ${module-bg}; border-radius: 100px; padding: 6px 14px; - box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); + box-shadow: none; } #clock, @@ -201,5 +201,11 @@ in { background-color: ${fg}; background-image: none; } + + #custom-osd { + padding: 1px 14px; + font-weight: 700; + color: ${fg}; + } ''; } diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index b0c4707..64e319a 100644 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -30,7 +30,7 @@ ../../home/system/waybar ../../home/system/swaync ../../home/system/swayosd - ../../home/system/rofi + ../../home/system/tofi ../../home/system/mime ../../home/system/udiskie diff --git a/themes/nixy.nix b/themes/nixy.nix index 9f4e9d4..5f76d2a 100644 --- a/themes/nixy.nix +++ b/themes/nixy.nix @@ -8,6 +8,7 @@ type = lib.types.attrs; default = { rounding = 20; + bar-height = 36; bar-rounding = 20 + 10; bar-thickness = 0; gaps-in = 8; diff --git a/todo b/todo index 92230b9..6dfd28c 100644 --- a/todo +++ b/todo @@ -2,9 +2,10 @@ - [ ] Configuration sway-nc - [ ] Configuration sway-osd - [ ] Configuration hyprlock -- [ ] Gaming/Focus mode +- [x] Gaming/Focus mode - [ ] Configuration Rofi/Drun - [ ] Helium plus rapide ? service/deamon ? - [ ] Ghostty service/deamon ? +- [ ] Tofi service/deamon ? - [ ] Clean files - [ ] Check claude: Sécu, mots en français, faute, ...