Added brightness notifications

This commit is contained in:
marc
2024-12-08 19:03:42 +01:00
parent 5fd64d47cd
commit ab380782c3
6 changed files with 87 additions and 31 deletions

View File

@@ -11,7 +11,7 @@
;; Fonts ;; Fonts
(setq doom-font (font-spec :family "Iosevka Nerd Font" :size 15)) (setq doom-font (font-spec :family "Iosevka Nerd Font" :size 15))
(setq doom-unicode-font (font-spec :family "Iosevka Nerd Font" :size 15)) (setq doom-symbol-font (font-spec :family "Iosevka Nerd Font" :size 15))
;; Themeing ;; Themeing
;; (use-package base16-theme ;; (use-package base16-theme

View File

@@ -0,0 +1,72 @@
#!/usr/bin/env bash
# Dependencies:
# - amixer
# - pactl
# - jq
# - libnotify
ACTION=$1
get_brightness() {
brightnessctl | \
grep "Current brightness" | \
sed -e 's/^\s\+Current brightness: [0-9]\+ (\([0-9]\+\)%).*$/\1/'
}
get_kb_brightness() {
brightnessctl -d platform::kbd_backlight | \
grep "Current brightness" | \
sed -e 's/^\s\+Current brightness: [0-9]\+ (\([0-9]\+\)%).*$/\1/'
}
notify() {
notify-send "$1" "$2" -e -t 1500 -h string:x-canonical-private-synchronous:brightness
}
set_brightness() {
# Set the brightness
TARGET=$1
brightnessctl set $TARGET > /dev/null
# Send a notification
BRIGHTNESS=$(get_brightness)
ACTION=$([[ ${TARGET:0:1} == "+" ]] && echo "Brightness Up" || echo "Brightness Down")
BRIGHTNESS_ICON="󰃠"
TITLE=$(echo "$BRIGHTNESS_ICON $ACTION")
BODY=$(echo "$BRIGHTNESS%")
notify "$TITLE" "$BODY"
}
set_kb_brightness() {
# Set the brightness
TARGET=$1
brightnessctl -d platform::kbd_backlight set $TARGET > /dev/null
# Send a notification
BRIGHTNESS=$(get_kb_brightness)
ACTION=$([[ ${TARGET:0:1} == "+" ]] && echo "Keyboard brightness Up" || echo "Keyboard brightness Down")
BRIGHTNESS_ICON="󰃠"
TITLE=$(echo "$BRIGHTNESS_ICON $ACTION")
BODY=$(echo "$BRIGHTNESS%")
notify "$TITLE" "$BODY"
}
case $ACTION in
set)
set_brightness $2
;;
kb_set)
set_kb_brightness $2
;;
*)
echo "Unknown action"
exit 1
;;
esac

View File

@@ -1,5 +1,5 @@
[[ -x "$(command -v eza)" ]] && { [[ -x "$(command -v eza)" ]] && {
alias ll="eza --group-directories-first --color=auto --git -la" alias ll="eza --group-directories-first --color=auto --icons=auto --git -la"
} || { } || {
alias ll="ls -alh --color=always --group-directories-first" alias ll="ls -alh --color=always --group-directories-first"
} }

View File

@@ -65,12 +65,24 @@ in
", XF86AudioNext, exec, playerctl next" ", XF86AudioNext, exec, playerctl next"
", XF86AudioPrev, exec, playerctl previous" ", XF86AudioPrev, exec, playerctl previous"
", XF86AudioStop, exec, playerctl stop" ", XF86AudioStop, exec, playerctl stop"
# Keyboard brightness control
"${hyprCfg.mod}, XF86MonBrightnessUp, exec, brightnessctl -d platform::kbd_backlight set +1"
"${hyprCfg.mod}, XF86MonBrightnessDown, exec, brightnessctl -d platform::kbd_backlight set -1"
]; ];
binde = [ binde = [
# Pulse Audio controls (volume) # Pulse Audio controls (keep button pressed)
", XF86AudioRaiseVolume, exec, $HOME/.config/grapheio/scripts/volume.sh set +5%" ", XF86AudioRaiseVolume, exec, $HOME/.config/grapheio/scripts/volume.sh set +5%"
", XF86AudioLowerVolume, exec, $HOME/.config/grapheio/scripts/volume.sh set -5%" ", XF86AudioLowerVolume, exec, $HOME/.config/grapheio/scripts/volume.sh set -5%"
# Brightness control (keep button pressed)
", XF86MonBrightnessUp, exec, $HOME/.config/grapheio/scripts/brightness.sh set +5%"
", XF86MonBrightnessDown, exec, $HOME/.config/grapheio/scripts/brightness.sh set 5%-"
# Keyboard brightness control (keep button pressed)
"${hyprCfg.mod}, XF86MonBrightnessUp, exec, $HOME/.config/grapheio/scripts/brightness.sh kb_set +1"
"${hyprCfg.mod}, XF86MonBrightnessDown, exec, $HOME/.config/grapheio/scripts/brightness.sh kb_set 1-"
]; ];
}; };

View File

@@ -14,11 +14,6 @@ in
zsh-powerlevel10k zsh-powerlevel10k
]; ];
# fonts.packages = with pkgs; [
# iosevka
# (nerdfonts.override { fonts = [ "Iosevka" ]; })
# ];
programs.zsh.enable = true; programs.zsh.enable = true;
hm.programs.zsh = { hm.programs.zsh = {
enable = true; enable = true;

View File

@@ -15,28 +15,5 @@ in
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
brightnessctl brightnessctl
]; ];
# - Hyprland keybindings ---------------------
hm.wayland.windowManager.hyprland.settings = lib.mkIf hyprCfg.enable {
bind = [
# Brightness control
", XF86MonBrightnessUp, exec, brightnessctl set +5%"
", XF86MonBrightnessDown, exec, brightnessctl set -5%"
# Keyboard brightness control
"${hyprCfg.mod}, XF86MonBrightnessUp, exec, brightnessctl -d platform::kbd_backlight set +1"
"${hyprCfg.mod}, XF86MonBrightnessDown, exec, brightnessctl -d platform::kbd_backlight set -1"
];
binde = [
# Brightness control (keep button pressed)
", XF86MonBrightnessUp, exec, brightnessctl set +5%"
", XF86MonBrightnessDown, exec, brightnessctl set 5%-"
# Keyboard brightness control (keep button pressed)
"${hyprCfg.mod}, XF86MonBrightnessUp, exec, brightnessctl -d platform::kbd_backlight set +1"
"${hyprCfg.mod}, XF86MonBrightnessDown, exec, brightnessctl -d platform::kbd_backlight set 1-"
];
};
}; };
} }