From 2ee75c629cdb30b994e36c9abff4e82621e00c73 Mon Sep 17 00:00:00 2001 From: Frantisek Bohacek Date: Sat, 30 Sep 2023 22:52:36 +0200 Subject: [PATCH] feat(laptop): add brightness program and adjustment in qtile --- hosts/laptop/default.nix | 4 ++-- modules/desktop/qtile/config/brightness.sh | 17 +++++++++++++++++ modules/desktop/qtile/config/config.py | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 modules/desktop/qtile/config/brightness.sh diff --git a/hosts/laptop/default.nix b/hosts/laptop/default.nix index 749b9cc..d4f5b64 100644 --- a/hosts/laptop/default.nix +++ b/hosts/laptop/default.nix @@ -59,8 +59,8 @@ networking.networkmanager.enable = true; - programs = { # No xbacklight, this is the alterantive - light.enable = true; + hardware = { # No xbacklight, this is the alterantive + brillo.enable = true; }; services = { diff --git a/modules/desktop/qtile/config/brightness.sh b/modules/desktop/qtile/config/brightness.sh new file mode 100644 index 0000000..4388a81 --- /dev/null +++ b/modules/desktop/qtile/config/brightness.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +function send_notification() { + brightness=$(printf "%.0f\n" $(brillo -G)) + dunstify -a "brightness" -u low -r 9991 -h int:value:"$brightness" -i "brightness-$1" "Brightness: $brightness %" +} + +case $1 in + up) + brillo -A 5 -q + ;; + down) + brillo -U 5 -q -c 2 + ;; +esac + +send_notification $1 diff --git a/modules/desktop/qtile/config/config.py b/modules/desktop/qtile/config/config.py index 7d224b1..d7a1c21 100644 --- a/modules/desktop/qtile/config/config.py +++ b/modules/desktop/qtile/config/config.py @@ -415,8 +415,8 @@ keys.extend([ EzKey('', lazy.spawn(f'{sequenceDetectorExec} -g mpris next')), EzKey('', lazy.spawn(f'{sequenceDetectorExec} -g mpris prev')), EzKey('', lazy.spawn('amixer -D pulse set Master 1+ toggle')), - EzKey('', lazy.spawn('xbacklight -inc 5')), - EzKey('', lazy.spawn('xbacklight -dec 5')), + EzKey('', lazy.spawn(f'{configLocation}/brightness.sh up')), + EzKey('', lazy.spawn(f'{configLocation}/brightness.sh down')), ]) # Printscreen -- 2.48.1