alien: enable and use i2c and ddcutil
This commit is contained in:
parent
8862a7ea35
commit
8535435805
2 changed files with 37 additions and 9 deletions
|
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
WAYBAR_SIGNAL=8 # SIGRTMIN+8
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
|
|
@ -15,15 +14,33 @@ if ! [[ "$value" =~ ^-?[0-9]+$ ]] || [ "$value" -lt -100 ] || [ "$value" -gt 100
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Apply brightness change with correct syntax
|
||||
# Determine which brightness control tool to use
|
||||
if command -v ddcutil >/dev/null 2>&1; then
|
||||
# Get current brightness
|
||||
current=$(ddcutil getvcp 10 | grep -oP 'current value =\s+\K\d+')
|
||||
|
||||
if [ -z "$current" ]; then
|
||||
echo "Error: failed to read current brightness from ddcutil" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Calculate new brightness (ddcutil uses absolute 0-100 scale)
|
||||
new=$((current + value))
|
||||
|
||||
# Clamp to valid range
|
||||
[ "$new" -lt 0 ] && new=0
|
||||
[ "$new" -gt 100 ] && new=100
|
||||
|
||||
# Set new brightness
|
||||
ddcutil setvcp 10 "$new" >/dev/null 2>&1
|
||||
else
|
||||
# Fallback to brightnessctl
|
||||
if [ "$value" -gt 0 ]; then
|
||||
brightnessctl s "+${value}%" >/dev/null
|
||||
elif [ "$value" -lt 0 ]; then
|
||||
brightnessctl s "${value#-}%-" >/dev/null
|
||||
else
|
||||
: # no-op for 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Notify Waybar to refresh
|
||||
pkill -RTMIN+"$WAYBAR_SIGNAL" waybar
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,18 @@
|
|||
{
|
||||
networking.hostName = "alien";
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
pkgs.ddcutil
|
||||
pkgs.mangohud
|
||||
];
|
||||
|
||||
# enable ddcutil
|
||||
users.users.sckova.extraGroups = [ "i2c" ];
|
||||
boot.initrd.kernelModules = [ "i2c-dev" ];
|
||||
services.udev.extraRules = ''
|
||||
KERNEL=="i2c-[0-9]*", GROUP="i2c", MODE="0660"
|
||||
'';
|
||||
|
||||
boot.binfmt.emulatedSystems = [
|
||||
"aarch64-linux"
|
||||
"riscv64-linux"
|
||||
|
|
@ -62,7 +74,6 @@
|
|||
};
|
||||
|
||||
environment = {
|
||||
systemPackages = [ pkgs.mangohud ];
|
||||
loginShellInit = ''
|
||||
[[ "$(tty)" = "/dev/tty1" ]] && ./gs.sh
|
||||
'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue