From d72357ed3e99244193e1a7c0bd721fef6e9729e5 Mon Sep 17 00:00:00 2001 From: Tomas Rivera <137088692+Totorile1@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:53:39 +0100 Subject: [PATCH] added first version of waybar config. Still some problems --- hosts/laptop/configuration.nix | 6 +- hosts/laptop/home.nix | 16 +- modules/home-manager/hyprland.nix | 6 +- modules/home-manager/waybar.nix | 649 ++++++++++++++++++++++++++++++ modules/scripts/colorpicker.nix | 70 ++++ modules/scripts/weatherwaybar.nix | 20 + 6 files changed, 763 insertions(+), 4 deletions(-) create mode 100644 modules/home-manager/waybar.nix create mode 100644 modules/scripts/colorpicker.nix create mode 100644 modules/scripts/weatherwaybar.nix diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index 1778911..7cb34a5 100755 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -120,7 +120,7 @@ services.upower.enable = true; programs.firefox.enable = true; # Allow unfree packages - nixpkgs.config.allowUnfree = true; + nixpkgs.config.allowUnfree = false; # List packages installed in system profile. To search, run: @@ -146,6 +146,10 @@ services.upower.enable = true; cmatrix swww #wallpaper daemon socat # Utility for bidirectional data transfer between two independent data channels (used to communicate between hyprland and swww to change wallpapers dinamically) +gcc # GNU C compiler +libreoffice +gruvbox-gtk-theme +hyprpicker #we need to install gnome and kde utils individually as we dont use gnome gnome-calculator snapshot diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index 8e6ec16..08144fd 100755 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -17,9 +17,11 @@ imports = [ ../../modules/home-manager/swaync.nix # notification daemon ../../modules/home-manager/neovim.nix # dont use nixvim. broken ../../modules/home-manager/rclone.nix +../../modules/home-manager/waybar.nix ]; + #programs.nixvim = { # enable = true; # imports = [ ../../modules/nixvim/neovim.nix ]; @@ -50,6 +52,10 @@ home.packages = [ (pkgs.callPackage ../../modules/scripts/cowsay.nix {}) (pkgs.callPackage ../../modules/scripts/wallpaper.nix {}) (pkgs.callPackage ../../modules/scripts/mountkdrive.nix {}) +(pkgs.callPackage ../../modules/scripts/weatherwaybar.nix {}) +(pkgs.callPackage ../../modules/scripts/colorpicker.nix {}) +#pkgs +pkgs.gruvbox-gtk-theme # # Adds the 'hello' command to your environment. It prints a friendly # # "Hello, world!" when run. # pkgs.hello @@ -68,7 +74,15 @@ home.packages = [ # '') ]; -#ssh config +#maybe migrate both of them in a separate file +# gtk config +gtk.theme = { +enable = true; +name = "Gruvbox-GTK-Theme-BL-MB"; +package = pkgs.gruvbox-gtk-theme; +}; + +# ssh config programs.ssh.enable = true; services.ssh-agent.enable = true; diff --git a/modules/home-manager/hyprland.nix b/modules/home-manager/hyprland.nix index 682f536..76893a6 100644 --- a/modules/home-manager/hyprland.nix +++ b/modules/home-manager/hyprland.nix @@ -99,7 +99,8 @@ in "$mod, E, exec, $file" "$mod, F, exec, $browser" "$mod+Shift, A, exec, rofi -show drun" - "$mod, Q, exec, custom-dontkillsteam" + "$mod, Q, exec, custom-dontkillsteam" + "Ctrl+Alt, W, exec, pkill waybar || waybar" #plugins keybindings ]; @@ -140,11 +141,12 @@ in "wl-paste --type text --watch cliphist store" # clipboard store text data "wl-paste --type image --watch cliphist store" # clipboard store image data "custom-batterynotify" - #wallpapers + #wallpapers/b "swww img ${wallpaper}" "swww-daemon" "sleep 1 && custom-wallpaper" "custom-mountkdrive" + "waybar" ]; # █░░ ▄▀█ █▄█ █▀█ █░█ ▀█▀ █▀ # █▄▄ █▀█ ░█░ █▄█ █▄█ ░█░ ▄█ diff --git a/modules/home-manager/waybar.nix b/modules/home-manager/waybar.nix new file mode 100644 index 0000000..84784f6 --- /dev/null +++ b/modules/home-manager/waybar.nix @@ -0,0 +1,649 @@ +{ config, pkgs, ... }: + + +{ + programs.waybar = { + enable = true; + settings = [ + { + layer = "top"; + position = "left"; + margin = "5 2 5 0"; + reload_style_on_change = true; + modules-left = [ + "hyprland/workspaces" + "group/info" + ]; + + + modules-center = [ + "hyprland/window" + ]; + modules-right = [ + "group/brightness" + "group/sound" + "group/connection" + "group/together" + "tray" + "group/power" + ]; + # groups settings are organized by alphabetical order + "group/audio" = { + orientation = "inherit"; + drawer = { + transition-duration = 500; + transition-left-to-right = false; + }; + items = [ + "pulseaudio" + "pulseaudio#mic" + "pulseaudio/slider" + ]; + }; + "group/bluetooth" = { + orientation = "inherit"; + drawer = { + transition-duration = 500; + transition-left-to-right = true; + }; + items = [ + "bluetooth" + "bluetooth#status" + ]; + }; + "group/brightness" = { + orientation = "inherit"; + drawer = { + transition-duration = 500; + transition-left-to-right = false; + }; + items = [ + "backlight" + "backlight/slider" + ]; + }; + "group/connection" = { + orientation = "inherit"; + items = [ "group/network" ]; + }; + "group/gcpu" = { + orientation = "inherit"; + items = [ + "custom/cpu-icon" + "temperature" + "cpu" + ]; + }; + "group/info" = { + orientation = "inherit"; + items = [ + "group/gcpu" + "memory" + "disk" + ]; + }; + "group/network" = { + orientation = "inherit"; + drawer = { + transition-duration = 500; + transition-left-to-right = true; + }; + items = [ + "network" + "network#speed" + ]; + }; + "group/power" = { + orientation = "inherit"; + drawer = { + transition-duration = 500; + transition-left-to-right = false; + }; + items = [ + "battery" + "power-profiles-daemon" + ]; + }; + "group/sound" = { + orientation = "inherit"; + items = [ + "group/audio" + "custom/notification" + ]; + }; + "group/together" = { + orientation = "inherit"; + items = [ + "group/utils" + "clock" + ]; + }; + "group/utils" = { + orientation = "inherit"; + drawer = { + transition-duration = 500; + transition-left-to-right = true; + }; + items = [ + "custom/weather" + "custom/colorpicker" + ]; + }; + # modules settings are organized by alphabetical order + backlight = { + device = "intel_backlight"; # my laptop is amd and it works + format = "{icon}"; + format-icons = [ + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + ]; + on-scroll-down = "brightnessctl s 5%-"; + on-scroll-up = "brightness s +5%"; + tooltip = true; + tooltip-format = "Brightness: {percent}%"; + smooth-scrolling-threshold = 1; + }; + "backlight/slider" = { + min = 5; + max = 100; + orientation = "vertical"; + device = "intel_backlight"; + }; + bluetooth = { + format-on = ""; + format-off = "󰂲"; + format-disabled = ""; + format-connected = ""; + tooltip-format = "{controller_alias}\t{controller_address}\n\n{num_connections} connected"; + tooltip-format-connected = "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}"; + tooltip-format-enumerate-connected = "{device_alias}\t{device_address}"; + tooltip-format-enumerate-connected-battery = "{device_alias}\t{device_address}\t{device_battery_percentage}%"; + }; + "bluetooth#status" = { + format-on = ""; + format-off = ""; + format-disabled = ""; + format-connected = "{num_connections}"; + format-connected-battery = "{device_battery_percentage}%"; + tooltip-format = "{controller_alias}\t{controller_address}\n\n{num_connections} connected"; + tooltip-format-connected = "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}"; + tooltip-format-enumerate-connected = "{device_alias}\t{device_address}"; + tooltip-format-enumerate-connected-battery = "{device_alias}\t{device_address}\t{device_battery_percentage}%"; + }; + clock = { + format = "{:%H\n%M}"; + tooltip-format = "{calendar}"; + calendar = { + mode = "month"; + mode-mon-col = 3; + weeks-pos = "right"; + on-scroll = 1; + on-click-right = "mode"; + format = { + today = "{}"; + }; + }; + }; + cpu = { + format = "{usage}%"; + }; + "custom/colorpicker" = { + format = ""; + return-type = "json"; + interval = "once"; + exec = "custom-colorpicker -j"; + on-click = "sleep 1 && ~/.config/waybar/scripts/colorpicker.sh"; + signal = 1; + }; + "custom/cpu-icon" = { + format = "󰻠"; + tooltip = false; + }; + "custom/mark" = { + format = ""; + tooltip = false; + }; + "custom/weather" = { + format = "{}"; + interval = 3600; + exec = "custom-weatherwaybar"; + return-type = "json"; + }; + disk = { + interval = 600; + format = " 󰋊 \n{percentage_used}󱉸"; + path = "/"; #maybe we should subtract ~/kdrive if it is counted + }; + "hyprland/window" = { + format = "{class}"; + rotate = 90; + }; + "hyprland/workspaces" = { + format = "{icon}"; + format-icons = { + "1" = ""; + "2" = ""; + "3" = ""; + "4" = ""; + "5" = ""; + "6" = ""; + "7" = ""; + "8" = ""; + "9" = ""; + "10" = ""; + "active" = ""; + "default" = ""; + }; + persistent-workspaces = { + "*" = [ 1 2 3 4 5 6 7 8 9 10 ]; + }; + }; + idle_inhibitor = { + format = "{icon}"; + tooltip-format-activated = "Idle Inhibitor is active"; + tooltip-format-deactivated = "Idle Inhibitor is not active"; + format-icons = { + activated = "󰔡"; + deactivated = "󰔢"; + }; + }; + memory = { + format = "  \n{:2}󱉸"; + }; + network = { + format = "{icon}"; + format-icons = { + wifi = [ "󰤨" ]; + ethernet = [ "󰈀" ]; + disconnected = [ "󰖪" ]; + }; + format-wifi = "󰤨"; + format-ethernet = "󰈀"; + format-disconnected = "󰖪"; + format-linked = "󰈁"; + tooltip = false; + }; + "network#speed" = { + format = " {bandwidthDownBits} "; + rotate = 90; + interval = 5; + tooltip-format = "{ipaddr}"; + tooltip-format-wifi = "{essid} ({signalStrength}%)  \n{ipaddr} | {frequency} MHz{icon} "; + tooltip-format-ethernet = "{ifname} 󰈀 \n{ipaddr} | {frequency} MHz{icon} "; + tooltip-format-disconnected = "Not Connected to any type of Network"; + tooltip = true; + }; + power-profiles-daemon = { + format = "{icon}"; + tooltip-format = "Power profile: {profile}\nDriver: {driver}"; + tooltip = true; + format-icons = { + default = ""; + performance = ""; + balanced = ""; + power-saver = ""; + }; + }; + pulseaudio = { + format = "{icon}"; + format-bluetooth = "{icon}"; + tooltip-format = "{volume}% {icon} | {desc}"; + format-muted = "󰖁"; + format-icons = { + headphones = "󰋌"; + handsfree = "󰋌"; + headset = "󰋌"; + phone = ""; + portable = ""; + car = " "; + default = [ + "󰕿" + "󰖀" + "󰕾" + ]; + }; + on-click = "volume mute"; + on-click-middle = "pavucontrol"; + on-scroll-up = "pactl set-sink-volume @DEFAULT_SINK@ +5%"; + on-scroll-down = "pactl set-sink-volume @DEFAULT_SINK@ -5%"; + smooth-scrolling-threshold = 1; + }; + "pulseaudio#mic" = { + format = "{format_source}"; + format-source = ""; + format-source-muted = ""; + tooltip-format = "{volume}% {format_source}"; + on-click = "pactl set-source-mute 0 toggle"; + on-scroll-down = "pactl set-source-volume 0 -1%"; + on-scroll-up = "pactl set-source-volume 0 +1%"; + }; + "pulseaudio/slider" = { + min = 0; + max = 140; + orientation = "vertical"; + }; + temperature = { + format = "{temperatureC}°C"; + format-critical = "{temperatureC}°C"; + interval = 10; + }; + tray = { + icon-size = 18; + spacing = 10; + }; + } + ]; # home-manager wants the whole config as a list of bars + style = '' +@define-color foreground #c5c5c5; +@define-color background #191919; +@define-color cursor #c5c5c5; + +@define-color color0 #191919; +@define-color color1 #3a3632; +@define-color color2 #582c1e; +@define-color color3 #423f39; +@define-color color4 #50473c; +@define-color color5 #634723; +@define-color color6 #BAA470; +@define-color color7 #8c8c8c; +@define-color color8 #525252; +@define-color color9 #4e4843; +@define-color color10 #763b28; +@define-color color11 #59554c; +@define-color color12 #6b5f51; +@define-color color13 #855f2f; +@define-color color14 #796d62; +@define-color color15 #c5c5c5; + +@define-color active @color6; + +* { + font-size: 16px; + font-family: "0xProto Nerd Font"; + min-width: 8px; + min-height: 0px; + border: none; + border-radius: 0; + box-shadow: none; + text-shadow: none; + padding: 0px; + +} + +window#waybar { + transition-property: background-color; + transition-duration: 0.5s; + border-radius: 8px; + border: 2px solid @active; + background: @background; + background: alpha(@background, 0.7); + color: lighter(@active); +} + +menu, +tooltip { + border-radius: 8px; + padding: 2px; + border: 1px solid lighter(@active); + background: alpha(@background, 0.6); + + color: lighter(@active); +} + +menu label, +tooltip label { + font-size: 14px; + color: lighter(@active); +} + +#submap, +#tray>.needs-attention { + animation-name: blink-active; + animation-duration: 1s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +.modules-right { + margin: 0px 6px 6px 6px; + border-radius: 4px; + background: alpha(@background, 0.4); + color: lighter(@active); +} + +.modules-left { + transition-property: background-color; + transition-duration: 0.5s; + margin: 6px 6px 6px 6px; + border-radius: 4px; + background: alpha(@background, 0.4); + color: lighter(@active); +} + +#gcpu, +#custom-github, +#memory, +#disk, +#together, +#submap, +#custom-weather +#custom-recorder, +#connection, +#cnoti, +#brightness, +#power, +#custom-updates, +#tray, +#audio, +#privacy, +#sound { + border-radius: 4px; + margin: 2px 2px 4px 2px; + background: alpha(darker(@active), 0.3); +} + +#custom-notifications { + padding-left: 4px; +} + +#custom-hotspot, +#custom-github, +#custom-notifications { + font-size: 14px; +} + +#custom-hotspot { + padding-right: 2px; +} + +#custom-vpn, +#custom-hotspot { + background: alpha(darker(@active), 0.3); +} + +#privacy-item { + padding: 6px 0px 6px 6px; +} + +#gcpu { + padding: 8px 0px 8px 0px; +} + +#custom-cpu-icon { + font-size: 25px; +} + +#custom-cputemp, +#disk, +#memory, +#cpu { + font-size: 14px; + font-weight: bold; +} + +#custom-github { + padding-top: 2px; + padding-right: 4px; +} + +#custom-dmark { + color: alpha(@foreground, 0.3); +} + +#submap { + margin-bottom: 0px; +} + +#workspaces { + margin: 0px 2px; + padding: 4px 0px 0px 0px; + border-radius: 8px; +} + +#workspaces button { + transition-property: background-color; + transition-duration: 0.5s; + color: @foreground; + background: transparent; + border-radius: 4px; + color: alpha(@foreground, 0.3); +} + +#workspaces button.urgent { + font-weight: bold; + color: @foreground; +} + +#workspaces button.active { + padding: 4px 2px; + background: alpha(@active, 0.4); + color: lighter(@active); + border-radius: 4px; +} + +#network.wifi { + padding-right: 4px; +} + +#submap { + min-width: 0px; + margin: 4px 6px 4px 6px; +} + +#tray { + padding: 4px 0px 4px 0px; +} + +#bluetooth { + padding-top: 2px; +} + +#window { + border-radius: 8px; + padding: 4px 14px; + margin: 4px 2px 4px 2px; +} + +#battery { + border-radius: 8px; + padding: 4px 0px; + margin: 4px 2px 4px 2px; +} + +#battery.discharging.warning { + animation-name: blink-yellow; + animation-duration: 1s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +#battery.discharging.critical { + animation-name: blink-red; + animation-duration: 1s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +#clock { + font-weight: bold; + padding: 4px 2px 2px 2px; +} + +#pulseaudio.mic { + border-radius: 4px; + color: @background; + background: alpha(darker(@foreground), 0.6); + padding-left: 4px; +} + +#backlight-slider slider, +#pulseaudio-slider slider { + background-color: transparent; + box-shadow: none; +} + +#backlight-slider trough, +#pulseaudio-slider trough { + margin-top: 4px; + min-width: 6px; + min-height: 60px; + border-radius: 8px; + background-color: alpha(@background, 0.6); +} + +#backlight-slider highlight, +#pulseaudio-slider highlight { + border-radius: 8px; + background-color: lighter(@active); +} + +#bluetooth.discoverable, +#bluetooth.discovering, +#bluetooth.pairable { + border-radius: 8px; + animation-name: blink-active; + animation-duration: 1s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +@keyframes blink-active { + to { + background-color: @active; + color: @foreground; + } +} + +@keyframes blink-red { + to { + background-color: #c64d4f; + color: @foreground; + } +} + +@keyframes blink-yellow { + to { + background-color: #cf9022; + color: @foreground; + } +} + ''; +}; +} diff --git a/modules/scripts/colorpicker.nix b/modules/scripts/colorpicker.nix new file mode 100644 index 0000000..6ed3496 --- /dev/null +++ b/modules/scripts/colorpicker.nix @@ -0,0 +1,70 @@ +{ writeShellApplication, hyprpicker, libnotify, toybox, ... }: + +writeShellApplication { + name = "custom-colorpicker"; + runtimeInputs = [ + hyprpicker + libnotify + toybox + ]; + text = '' +check() { + command -v "$1" 1>/dev/null +} + +notify() { + check notify-send && { + notify-send -a "Color Picker" "$@" + return + } + echo "$@" +} + +loc="$HOME/.cache/colorpicker" +[ -d "$loc" ] || mkdir -p "$loc" +[ -f "$loc/colors" ] || touch "$loc/colors" + +limit=10 + +[[ $# -eq 1 && $1 = "-l" ]] && { + cat "$loc/colors" + exit +} + +[[ $# -eq 1 && $1 = "-j" ]] && { + text="$(head -n 1 "$loc/colors")" + + mapfile -t allcolors < <(tail -n +2 "$loc/colors") + # allcolors=($(tail -n +2 "$loc/colors")) + tooltip=" COLORS\n\n" + + tooltip+="-> $text 󰸌 \n" + for i in "''${allcolors[@]}"; do + tooltip+=" $i 󰸌 \n" + done + + cat <󰸌", "tooltip":"$tooltip"} +EOF + + exit +} + +check hyprpicker || { + notify "hyprpicker is not installed" + exit +} +killall -q hyprpicker +color=$(hyprpicker) + +check wl-copy && { + echo "$color" | sed -z 's/\n//g' | wl-copy +} + +prevColors=$(head -n $((limit - 1)) "$loc/colors") +echo "$color" >"$loc/colors" +echo "$prevColors" >>"$loc/colors" +sed -i '/^$/d' "$loc/colors" +pkill -RTMIN+1 waybar +''; +} diff --git a/modules/scripts/weatherwaybar.nix b/modules/scripts/weatherwaybar.nix new file mode 100644 index 0000000..c14ce35 --- /dev/null +++ b/modules/scripts/weatherwaybar.nix @@ -0,0 +1,20 @@ +{ writeShellApplication, curl, ... }: + +writeShellApplication { + name = "custom-weatherwaybar"; + runtimeInputs = [ + curl + ]; + text = '' +PATTERN="C" +PATTERN2=" " +TEXT1="''$(curl -s "https://wttr.in/?format=%c")" +TEXT1=''${TEXT1/$PATTERN2/} +TEXT2="''$(curl -s "https://wttr.in/?format=%t")" +TEXT2=''${TEXT2/$PATTERN/} +TEXT3="''$(curl -s "https://wttr.in/?format=%f")" +TEXT3=''${TEXT3/$PATTERN/} +printf '{"text":"%s\n%s\n%s", "tooltip": false, "class": "weather"}\n' \ + "$TEXT1" "$TEXT2" "$TEXT3" +''; +}