nwg-panel: add a button to toggle the flashlight on moby
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
# - use sane-sysload
|
# - use sane-sysload
|
||||||
{
|
{
|
||||||
controlsSettingsComponents,
|
controlsSettingsComponents,
|
||||||
|
controlsSettingsCustomItems,
|
||||||
height,
|
height,
|
||||||
locker,
|
locker,
|
||||||
modulesRight,
|
modulesRight,
|
||||||
@@ -82,7 +83,7 @@
|
|||||||
# commands.battery = ""; #< optional action to perform when battery icon is clicked in the drop-down menu
|
# commands.battery = ""; #< optional action to perform when battery icon is clicked in the drop-down menu
|
||||||
components = controlsSettingsComponents;
|
components = controlsSettingsComponents;
|
||||||
click-closes = false;
|
click-closes = false;
|
||||||
custom-items = [];
|
custom-items = controlsSettingsCustomItems;
|
||||||
css-name = "controls-window";
|
css-name = "controls-window";
|
||||||
hover-opens = false;
|
hover-opens = false;
|
||||||
icon-size = 16;
|
icon-size = 16;
|
||||||
|
@@ -13,6 +13,19 @@ let
|
|||||||
};
|
};
|
||||||
in
|
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 = {
|
sane.programs.nwg-panel = {
|
||||||
configOption = with lib; mkOption {
|
configOption = with lib; mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
@@ -44,6 +57,15 @@ in
|
|||||||
s6 service to start which can lock the screen
|
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";
|
battery = mkEnableOption' true "display battery status";
|
||||||
brightness = mkEnableOption' true "display backlight level and slider";
|
brightness = mkEnableOption' true "display backlight level and slider";
|
||||||
mediaTitle = mkEnableOption' true "display title of current song/media";
|
mediaTitle = mkEnableOption' true "display title of current song/media";
|
||||||
@@ -117,7 +139,10 @@ in
|
|||||||
});
|
});
|
||||||
|
|
||||||
suggestedPrograms = [
|
suggestedPrograms = [
|
||||||
|
"brightnessctl"
|
||||||
"pactl" # pactl required by `per-app-volume` component.
|
"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 {
|
fs.".config/nwg-panel/style.css".symlink.target = pkgs.substituteAll {
|
||||||
@@ -139,6 +164,15 @@ in
|
|||||||
"battery"
|
"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 = [
|
modulesRight = [
|
||||||
"playerctl"
|
"playerctl"
|
||||||
] ++ lib.optionals cfg.config.sysload [
|
] ++ lib.optionals cfg.config.sysload [
|
||||||
@@ -157,6 +191,7 @@ in
|
|||||||
];
|
];
|
||||||
sandbox.extraPaths = [
|
sandbox.extraPaths = [
|
||||||
"/sys/class/backlight"
|
"/sys/class/backlight"
|
||||||
|
"/sys/class/leds" #< for torch/flashlight on moby
|
||||||
"/sys/class/power_supply" #< for the battery indicator
|
"/sys/class/power_supply" #< for the battery indicator
|
||||||
"/sys/devices"
|
"/sys/devices"
|
||||||
];
|
];
|
||||||
|
12
hosts/common/programs/nwg-panel/torch-toggle
Executable file
12
hosts/common/programs/nwg-panel/torch-toggle
Executable file
@@ -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
|
@@ -283,6 +283,7 @@ in
|
|||||||
# dd if=${pkgs.tow-boot-pinephone}/Tow-Boot.noenv.bin of=$out bs=1024 seek=8 conv=notrunc
|
# 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 = {
|
sane.programs.gps-share.config = {
|
||||||
device = "/dev/ttyUSB1";
|
device = "/dev/ttyUSB1";
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user