forked from mirrors_public/oddlama_nix-config
feat: add brightness keybinds and notification
This commit is contained in:
parent
4d42043895
commit
a6c643d8b1
6 changed files with 73 additions and 4 deletions
1
pkgs/scripts/assets/brightness-decrease.svg
Symbolic link
1
pkgs/scripts/assets/brightness-decrease.svg
Symbolic link
|
@ -0,0 +1 @@
|
|||
brightness.svg
|
1
pkgs/scripts/assets/brightness-increase.svg
Symbolic link
1
pkgs/scripts/assets/brightness-increase.svg
Symbolic link
|
@ -0,0 +1 @@
|
|||
brightness.svg
|
35
pkgs/scripts/assets/brightness.svg
Normal file
35
pkgs/scripts/assets/brightness.svg
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
viewBox="0 0 512 512" xml:space="preserve">
|
||||
<path style="fill:#e3e6eb;" d="M256,84.426c-94.607,0-171.574,76.968-171.574,171.574S161.393,427.574,256,427.574
|
||||
S427.574,350.607,427.574,256S350.607,84.426,256,84.426z"/>
|
||||
<path style="fill:#101419;" d="M257.626,100.776v310.448c84.851-0.877,153.608-70.166,153.608-155.224
|
||||
S342.478,101.653,257.626,100.776z"/>
|
||||
<path style="fill:#101419;" d="M257.626,100.776C326.166,101.85,381.665,171.07,381.665,256s-55.5,154.15-124.039,155.224
|
||||
c-0.543,0.01-1.084,0.01-1.626,0.01L206.719,256L256,100.766C256.542,100.766,257.084,100.766,257.626,100.776z"/>
|
||||
<g>
|
||||
<path style="fill:#e3e6eb;" d="M100.766,256c0,85.597,69.637,155.234,155.234,155.234V100.766
|
||||
C170.403,100.766,100.766,170.403,100.766,256z"/>
|
||||
<path style="fill:#e3e6eb;" d="M256,59.915c-4.512,0-8.17-3.658-8.17-8.17V8.17c0-4.512,3.658-8.17,8.17-8.17s8.17,3.658,8.17,8.17
|
||||
v43.574C264.17,56.257,260.512,59.915,256,59.915z"/>
|
||||
<path style="fill:#e3e6eb;" d="M111.569,119.739c-2.09,0-4.182-0.797-5.777-2.393l-30.812-30.81c-3.191-3.191-3.191-8.364,0-11.554
|
||||
c3.191-3.191,8.364-3.191,11.554,0l30.812,30.812c3.191,3.191,3.191,8.364,0,11.554
|
||||
C115.751,118.942,113.661,119.739,111.569,119.739z"/>
|
||||
<path style="fill:#e3e6eb;" d="M51.745,264.17H8.17C3.658,264.17,0,260.512,0,256s3.658-8.17,8.17-8.17h43.574
|
||||
c4.512,0,8.17,3.658,8.17,8.17S56.257,264.17,51.745,264.17z"/>
|
||||
<path style="fill:#e3e6eb;" d="M80.758,439.413c-2.09,0-4.182-0.797-5.777-2.393c-3.191-3.191-3.191-8.364,0-11.554l30.812-30.811
|
||||
c3.191-3.191,8.364-3.191,11.554,0c3.191,3.191,3.191,8.364,0,11.554l-30.81,30.811C84.94,438.614,82.849,439.413,80.758,439.413z"
|
||||
/>
|
||||
<path style="fill:#e3e6eb;" d="M256,512c-4.512,0-8.17-3.658-8.17-8.17v-43.574c0-4.512,3.658-8.17,8.17-8.17s8.17,3.658,8.17,8.17
|
||||
v43.574C264.17,508.342,260.512,512,256,512z"/>
|
||||
<path style="fill:#e3e6eb;" d="M431.242,439.413c-2.09,0-4.182-0.797-5.777-2.393l-30.812-30.811
|
||||
c-3.191-3.191-3.191-8.364,0-11.554c3.191-3.191,8.364-3.191,11.554,0l30.811,30.811c3.191,3.191,3.191,8.364,0,11.554
|
||||
C435.424,438.614,433.333,439.413,431.242,439.413z"/>
|
||||
<path style="fill:#e3e6eb;" d="M503.83,264.17h-43.574c-4.512,0-8.17-3.658-8.17-8.17s3.658-8.17,8.17-8.17h43.574
|
||||
c4.512,0,8.17,3.658,8.17,8.17S508.342,264.17,503.83,264.17z"/>
|
||||
<path style="fill:#e3e6eb;" d="M400.431,119.739c-2.091,0-4.182-0.797-5.777-2.393c-3.191-3.191-3.191-8.364,0-11.554
|
||||
l30.812-30.812c3.191-3.191,8.364-3.191,11.554,0c3.191,3.191,3.191,8.364,0,11.554l-30.811,30.812
|
||||
C404.612,118.942,402.521,119.739,400.431,119.739z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.8 KiB |
30
pkgs/scripts/brightness.nix
Normal file
30
pkgs/scripts/brightness.nix
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
writeShellApplication,
|
||||
bc,
|
||||
libnotify,
|
||||
brightnessctl,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "brightness";
|
||||
text = ''
|
||||
set -euo pipefail
|
||||
|
||||
${brightnessctl}/bin/brightnessctl "$1" "$2"
|
||||
case "$2" in
|
||||
"+"*) image=${./assets}/brightness-increase.svg ;;
|
||||
*"-") image=${./assets}/brightness-decrease.svg ;;
|
||||
esac
|
||||
|
||||
max=$(${brightnessctl}/bin/brightnessctl -m max)
|
||||
value=$(${brightnessctl}/bin/brightnessctl -m get)
|
||||
value=$(${bc}/bin/bc <<< "scale=0; 100*$value/$max")
|
||||
${libnotify}/bin/notify-send \
|
||||
"Brightness" \
|
||||
--hint=string:image-path:"$image" \
|
||||
--hint=int:value:"$value" \
|
||||
--hint="string:wired-tag:indicator" \
|
||||
--hint="string:wired-note:brightness" \
|
||||
--expire-time=1000 \
|
||||
|| true
|
||||
'';
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
_final: prev: {
|
||||
scripts = {
|
||||
brightness = prev.callPackage ./brightness.nix {};
|
||||
screenshot-area = prev.callPackage ./screenshot-area.nix {};
|
||||
screenshot-area-scan-qr = prev.callPackage ./screenshot-area-scan-qr.nix {};
|
||||
screenshot-screen = prev.callPackage ./screenshot-screen.nix {};
|
||||
|
|
|
@ -70,11 +70,12 @@ in {
|
|||
"XF86AudioLowerVolume" = "exec --no-startup-id ${getExe pkgs.scripts.volume} set-volume @DEFAULT_AUDIO_SINK@ 5%-";
|
||||
"XF86AudioMute" = "exec --no-startup-id ${getExe pkgs.scripts.volume} set-mute @DEFAULT_AUDIO_SINK@ toggle";
|
||||
"XF86AudioMicMute" = "exec --no-startup-id ${getExe pkgs.scripts.volume} set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
|
||||
"XF86AudioPlay" = "exec --no-startup-id ${getExe pkgs.playerctl} play-pause";
|
||||
"XF86AudioNext" = "exec --no-startup-id ${getExe pkgs.playerctl} next";
|
||||
"XF86AudioPrev" = "exec --no-startup-id ${getExe pkgs.playerctl} previous";
|
||||
"XF86MonBrightnessUp" = "exec --no-startup-id ${getExe pkgs.scripts.brightness} set +5%";
|
||||
"XF86MonBrightnessDown" = "exec --no-startup-id ${getExe pkgs.scripts.brightness} set 5%-";
|
||||
}
|
||||
# // optionalAttrs useBacklight {
|
||||
# "XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5";
|
||||
# "XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 5";
|
||||
# }
|
||||
// {
|
||||
"Menu" = "exec ${cfg.menu}";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue