diff --git a/hosts/common/programs/nwg-panel/config.nix b/hosts/common/programs/nwg-panel/config.nix index 1cb6b6909..cc3e111f1 100644 --- a/hosts/common/programs/nwg-panel/config.nix +++ b/hosts/common/programs/nwg-panel/config.nix @@ -7,6 +7,7 @@ # - use sane-sysload { controlsSettingsComponents, + controlsSettingsCustomItems, height, locker, modulesRight, @@ -82,7 +83,7 @@ # commands.battery = ""; #< optional action to perform when battery icon is clicked in the drop-down menu components = controlsSettingsComponents; click-closes = false; - custom-items = []; + custom-items = controlsSettingsCustomItems; css-name = "controls-window"; hover-opens = false; icon-size = 16; diff --git a/hosts/common/programs/nwg-panel/default.nix b/hosts/common/programs/nwg-panel/default.nix index 6d0b567c7..18d974afc 100644 --- a/hosts/common/programs/nwg-panel/default.nix +++ b/hosts/common/programs/nwg-panel/default.nix @@ -13,6 +13,19 @@ let }; in { + sane.programs.torch-toggle = { + packageUnwrapped = pkgs.static-nix-shell.mkBash { + pname = "torch-toggle"; + pkgs = [ "brightnessctl" ]; + srcRoot = ./.; + }; + + suggestedPrograms = [ + "brightnessctl" + ]; + sandbox.enable = false; # trivial, and all deps are sandboxed + }; + sane.programs.nwg-panel = { configOption = with lib; mkOption { default = {}; @@ -44,6 +57,15 @@ in s6 service to start which can lock the screen ''; }; + torch = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + device name for the torch (flashlight), if any. + find with `brightnessctl -l` + ''; + example = "white:flash"; + }; battery = mkEnableOption' true "display battery status"; brightness = mkEnableOption' true "display backlight level and slider"; mediaTitle = mkEnableOption' true "display title of current song/media"; @@ -117,7 +139,10 @@ in }); suggestedPrograms = [ + "brightnessctl" "pactl" # pactl required by `per-app-volume` component. + ] ++ lib.optionals (cfg.config.torch != null) [ + "torch-toggle" ]; fs.".config/nwg-panel/style.css".symlink.target = pkgs.substituteAll { @@ -139,6 +164,15 @@ in "battery" ] ; + controlsSettingsCustomItems = lib.optionals (cfg.config.torch != null) [ + { + name = "Torch"; + # icons: find them in /etc/profiles/per-user/colin/share/icons + # display-brightness-symbolic, keyboard-brightness-symbolic, night-light-symbolic + icon = "display-brightness-symbolic"; + cmd = "torch-toggle ${cfg.config.torch}"; + } + ]; modulesRight = [ "playerctl" ] ++ lib.optionals cfg.config.sysload [ @@ -157,6 +191,7 @@ in ]; sandbox.extraPaths = [ "/sys/class/backlight" + "/sys/class/leds" #< for torch/flashlight on moby "/sys/class/power_supply" #< for the battery indicator "/sys/devices" ]; diff --git a/hosts/common/programs/nwg-panel/torch-toggle b/hosts/common/programs/nwg-panel/torch-toggle new file mode 100755 index 000000000..c2495f660 --- /dev/null +++ b/hosts/common/programs/nwg-panel/torch-toggle @@ -0,0 +1,12 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p bash -p brightnessctl +dev="$1" +if [ -z "$dev" ]; then + dev="white:flash" +fi + +if [ "$(brightnessctl -d "$dev" get)" -gt 0 ]; then + brightnessctl -q -d "$dev" set "0%" +else + brightnessctl -q -d "$dev" set "100%" +fi diff --git a/hosts/modules/hal/pine64.nix b/hosts/modules/hal/pine64.nix index 1a6dd826b..8b8f98a42 100644 --- a/hosts/modules/hal/pine64.nix +++ b/hosts/modules/hal/pine64.nix @@ -283,6 +283,7 @@ in # dd if=${pkgs.tow-boot-pinephone}/Tow-Boot.noenv.bin of=$out bs=1024 seek=8 conv=notrunc # ''; + sane.programs.nwg-panel.config.torch = "white:flash"; sane.programs.gps-share.config = { device = "/dev/ttyUSB1"; };