feat: fv43u brightness control

This commit is contained in:
2025-01-17 22:42:34 +01:00
parent 8a1ff0202f
commit 998a7b9166
2 changed files with 81 additions and 15 deletions

View File

@@ -2,6 +2,7 @@
lib, lib,
config, config,
username, username,
pkgs,
... ...
}: }:
with lib; with lib;
@@ -19,19 +20,66 @@ in
hardware.gbmonctl.enable = true; hardware.gbmonctl.enable = true;
boot.kernelParams = [ "video=3840x2160@120" ]; boot.kernelParams = [ "video=3840x2160@120" ];
home-manager.users.${username}.wayland.windowManager.hyprland.settings = { home-manager.users.${username} = {
general.layout = "master"; wayland.windowManager.hyprland.settings = {
master = { general.layout = "master";
orientation = "center"; master = {
always_center_master = true; orientation = "center";
mfact = 0.4; 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" programs.waybar.settings.mainBar."custom/brightness" =
"DP-3,addreserved,340,0,0,0" let
]; tmpFile = "${config.home-manager.users.${username}.xdg.configHome}/gbmonctl-brightness";
xwayland.force_zero_scaling = true; in
misc.vrr = 2; # VA suffers from VRR flicker {
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 = { programs.steam.gamescopeSession = {

View File

@@ -23,6 +23,9 @@ in
reload_style_on_change = true; reload_style_on_change = true;
exclusive = true; exclusive = true;
modules-left = [
# "hyprland/workspaces"
];
modules-center = [ modules-center = [
"clock" "clock"
"systemd-failed-units" "systemd-failed-units"
@@ -31,14 +34,27 @@ in
"privacy" "privacy"
"gamemode" "gamemode"
"tray" "tray"
"custom/brightness"
"custom/theme" "custom/theme"
#"network"
#"pulseaudio"
#"bluetooth"
]; ];
"hyprland/workspaces" = {
format = "{windows}";
window-rewrite = {
"class<firefox>" = "󰈹";
"class<thunderbird>" = "";
"class<neovide>" = "";
"class<kitty>" = "";
"class<OrcaSlicer>" = "󰹛";
"class<blender>" = "";
"class<steam>" = "";
};
window-rewrite-default = "";
};
"custom/theme" = { "custom/theme" = {
return-type = "json"; return-type = "json";
exec-on-event = true;
exec = pkgs.writeShellScript "waybar-theme" '' exec = pkgs.writeShellScript "waybar-theme" ''
if [ $(theme mode) = "dark" ]; then if [ $(theme mode) = "dark" ]; then
echo '{"text": "", "tooltip": "Switch to light theme"}' echo '{"text": "", "tooltip": "Switch to light theme"}'
@@ -46,6 +62,8 @@ in
echo '{"text": "", "tooltip": "Switch to dark theme"}' echo '{"text": "", "tooltip": "Switch to dark theme"}'
fi fi
''; '';
exec-if = "sleep 1";
interval = "once";
on-click = "theme toggle"; on-click = "theme toggle";
}; };
}; };