diff --git a/modules/nixos/hardware/fv43u.nix b/modules/nixos/hardware/fv43u.nix index 3a90c05..88c51b1 100644 --- a/modules/nixos/hardware/fv43u.nix +++ b/modules/nixos/hardware/fv43u.nix @@ -2,6 +2,7 @@ lib, config, username, + pkgs, ... }: with lib; @@ -19,19 +20,66 @@ in hardware.gbmonctl.enable = true; boot.kernelParams = [ "video=3840x2160@120" ]; - home-manager.users.${username}.wayland.windowManager.hyprland.settings = { - general.layout = "master"; - master = { - orientation = "center"; - always_center_master = true; - mfact = 0.4; + home-manager.users.${username} = { + wayland.windowManager.hyprland.settings = { + general.layout = "master"; + master = { + orientation = "center"; + always_center_master = true; + mfact = 0.4; + }; + monitor = [ + "DP-3,3840x2160@120,0x0,1,bitdepth,10" + "DP-3,addreserved,340,0,0,0" + ]; + xwayland.force_zero_scaling = true; + misc.vrr = 2; # VA suffers from VRR flicker }; - monitor = [ - "DP-3,3840x2160@120,0x0,1,bitdepth,10" - "DP-3,addreserved,340,0,0,0" - ]; - xwayland.force_zero_scaling = true; - misc.vrr = 2; # VA suffers from VRR flicker + + programs.waybar.settings.mainBar."custom/brightness" = + let + tmpFile = "${config.home-manager.users.${username}.xdg.configHome}/gbmonctl-brightness"; + in + { + return-type = "json"; + exec = pkgs.writeShellScript "waybar-brightness" '' + BRIGHTNESS=$(cat ${tmpFile} || echo "0") + if [ "$BRIGHTNESS" -lt ${toString (100 / 7 * 1)} ]; then + ICON="󰃚" + elif [ "$BRIGHTNESS" -lt ${toString (100 / 7 * 2)} ]; then + ICON="󰃛" + elif [ "$BRIGHTNESS" -lt ${toString (100 / 7 * 3)} ]; then + ICON="󰃜" + elif [ "$BRIGHTNESS" -lt ${toString (100 / 7 * 4)} ]; then + ICON="󰃝" + elif [ "$BRIGHTNESS" -lt ${toString (100 / 7 * 5)} ]; then + ICON="󰃞" + elif [ "$BRIGHTNESS" -lt ${toString (100 / 7 * 6)} ]; then + ICON="󰃟" + else + ICON="󰃠" + fi + + echo "{\"text\": \"$ICON $BRIGHTNESS%\"}" + ''; + on-scroll-up = pkgs.writeShellScript "waybar-brightness-up" '' + BRIGHTNESS=$(cat ${tmpFile} || echo "0") + BRIGHTNESS=$((BRIGHTNESS + 5)) + BRIGHTNESS=$((BRIGHTNESS > 100 ? 100 : BRIGHTNESS)) + echo $BRIGHTNESS > ${tmpFile} + ${pkgs.gbmonctl}/bin/gbmonctl -prop brightness -val $BRIGHTNESS + ''; + on-scroll-down = pkgs.writeShellScript "waybar-brightness-up" '' + BRIGHTNESS=$(cat ${tmpFile} || echo "0") + BRIGHTNESS=$((BRIGHTNESS - 5)) + BRIGHTNESS=$((BRIGHTNESS < 0 ? 0 : BRIGHTNESS)) + echo $BRIGHTNESS > ${tmpFile} + ${pkgs.gbmonctl}/bin/gbmonctl -prop brightness -val $BRIGHTNESS + ''; + exec-on-event = true; + exec-if = "sleep 0.1"; + interval = "once"; + }; }; programs.steam.gamescopeSession = { diff --git a/modules/nixos/shell/waybar.nix b/modules/nixos/shell/waybar.nix index cceeadb..2f2cfe2 100644 --- a/modules/nixos/shell/waybar.nix +++ b/modules/nixos/shell/waybar.nix @@ -23,6 +23,9 @@ in reload_style_on_change = true; exclusive = true; + modules-left = [ + # "hyprland/workspaces" + ]; modules-center = [ "clock" "systemd-failed-units" @@ -31,14 +34,27 @@ in "privacy" "gamemode" "tray" + "custom/brightness" "custom/theme" - #"network" - #"pulseaudio" - #"bluetooth" ]; + "hyprland/workspaces" = { + format = "{windows}"; + window-rewrite = { + "class" = "󰈹"; + "class" = ""; + "class" = ""; + "class" = ""; + "class" = "󰹛"; + "class" = ""; + "class" = ""; + }; + window-rewrite-default = ""; + }; + "custom/theme" = { return-type = "json"; + exec-on-event = true; exec = pkgs.writeShellScript "waybar-theme" '' if [ $(theme mode) = "dark" ]; then echo '{"text": "", "tooltip": "Switch to light theme"}' @@ -46,6 +62,8 @@ in echo '{"text": "", "tooltip": "Switch to dark theme"}' fi ''; + exec-if = "sleep 1"; + interval = "once"; on-click = "theme toggle"; }; };