dotfiles/modules/nixos/graphical/rofi/brightness.nix

51 lines
1.3 KiB
Nix
Raw Permalink Normal View History

2023-04-02 19:52:45 +00:00
{ config, pkgs, ... }:
let
rofi = config.home-manager.users.${config.user}.programs.rofi.finalPackage;
2024-04-20 13:42:06 +00:00
in
{
2023-04-02 19:52:45 +00:00
# Adapted from:
# A rofi powered menu to execute brightness choices.
2024-04-20 13:42:06 +00:00
config.brightnessCommand = builtins.toString (
pkgs.writeShellScript "brightness" ''
2023-04-02 19:52:45 +00:00
dimmer="󰃝"
medium="󰃟"
brighter="󰃠"
2023-04-02 19:52:45 +00:00
chosen=$(printf '%s;%s;%s\n' \
"$dimmer" \
"$medium" \
"$brighter" \
| ${rofi}/bin/rofi \
-theme-str '@import "brightness.rasi"' \
-hover-select \
-me-select-entry ''' \
-me-accept-entry MousePrimary \
-dmenu \
-sep ';' \
-selected-row 1)
2023-04-02 19:52:45 +00:00
case "$chosen" in
"$dimmer")
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 25; ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 25
2023-04-02 19:52:45 +00:00
;;
"$medium")
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 75; ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 75
2023-04-02 19:52:45 +00:00
;;
"$brighter")
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 100; ${pkgs.ddcutil}/bin/ddcutil --disable-dynamic-sleep --display 2 setvcp 10 100
2023-04-02 19:52:45 +00:00
;;
*) exit 1 ;;
esac
2024-04-20 13:42:06 +00:00
''
);
2023-04-02 19:52:45 +00:00
}