{ pkgs, ... }: let volume-control = pkgs.writeShellScriptBin "volume-control" '' TAG="audio-volume" function get_vol { ${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print int($2 * 100)}' } case $1 in up) ${pkgs.wireplumber}/bin/wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+ ;; down) ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- ;; mute) ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;; esac vol=$(get_vol) is_muted=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep "MUTED") if [ -n "$is_muted" ]; then ${pkgs.dunst}/bin/dunstify -a "Volume" -u low \ -h string:x-canonical-private-synchronous:$TAG \ "Volume: Muted" else ${pkgs.dunst}/bin/dunstify -a "Volume" -u low \ -h string:x-canonical-private-synchronous:$TAG \ -h int:value:"$vol" \ "Volume: $vol%" fi ''; brightness-control = pkgs.writeShellScriptBin "brightness-control" '' TAG="screen-brightness" case $1 in up) ${pkgs.brightnessctl}/bin/brightnessctl set +5% ;; down) ${pkgs.brightnessctl}/bin/brightnessctl set 5%- ;; esac # Get current percentage current=$(${pkgs.brightnessctl}/bin/brightnessctl info | grep -oP '\(\K[0-9]+(?=%\))') ${pkgs.dunst}/bin/dunstify -a "Brightness" -u low \ -h string:x-canonical-private-synchronous:$TAG \ -h int:value:"$current" \ "Brightness: $current%" ''; mic-control = pkgs.writeShellScriptBin "mic-control" '' TAG="audio-mic" case $1 in toggle) ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle ;; esac is_muted=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep "MUTED") if [ -n "$is_muted" ]; then ${pkgs.dunst}/bin/dunstify -a "Microphone" -u low \ -h string:x-canonical-private-synchronous:$TAG \ "Microphone: Muted" else ${pkgs.dunst}/bin/dunstify -a "Microphone" -u low \ -h string:x-canonical-private-synchronous:$TAG \ "Microphone: On" fi ''; beesettings = pkgs.writeShellScriptBin "beesettings" '' CONFIG_FILE="$HOME/.config/beeSettings" WALL_DIR="$HOME/Pictures/Wallpapers" init_settings() { if [ ! -f "$CONFIG_FILE" ]; then mkdir -p "$(dirname "$CONFIG_FILE")" echo -e "theme=dark\nnightlight=off\nwallpaper=$WALL_DIR/default.jpg" > "$CONFIG_FILE" fi } get_val() { grep "^$1=" "$CONFIG_FILE" | cut -d'=' -f2; } set_val() { sed -i "s|^$1=.*|$1=$2|" "$CONFIG_FILE"; } set_layout() { mmsg -l "$1"; } apply_all() { local theme=$(get_val "theme") local wall=$(get_val "wallpaper") local mode_flag="dark" [ "$theme" == "light" ] && mode_flag="light" matugen image "$wall" -m "$mode_flag" -t scheme-content --source-color-index 0 2>/dev/null wallust -q -s run "$wall" 2>/dev/null dconf write /org/gnome/desktop/interface/color-scheme "'prefer-$mode_flag'" if [ -z "$WAYLAND_DISPLAY" ] && [ -n "$DISPLAY" ]; then xrdb -merge "$HOME/.Xresources" fi [ -f "$HOME/.config/sequences" ] && sh "$HOME/.config/sequences" } cmd_wall() { list_walls() { for wall in "$WALL_DIR"/*.{jpg,jpeg,png,webp}; do [ -f "$wall" ] && echo -en "$(basename "$wall")\0icon\x1f$wall\n" done } SELECTED=$(list_walls | rofi -dmenu -i -p "Wallpaper" \ -show-icons \ -theme-str 'element { orientation: vertical; padding: 15px; }' \ -theme-str 'element-icon { size: 10em; horizontal-align: 0.5; }' \ -theme-str 'listview { columns: 3; lines: 2; }' \ -theme-str 'window { width: 50%; }') if [ -n "$SELECTED" ]; then FULL_PATH="$WALL_DIR/$SELECTED" set_val "wallpaper" "$FULL_PATH" if [ -n "$WAYLAND_DISPLAY" ]; then if command -v swww >/dev/null 2>&1; then swww img "$FULL_PATH" --transition-type grow --transition-fps 120 --transition-step 60 --transition-duration 1.5 else pkill swaybg; swaybg -i "$FULL_PATH" -m fill & fi else feh --bg-fill "$FULL_PATH" fi apply_all fi } cmd_settings() { local theme=$(get_val "theme") local nl=$(get_val "nightlight") CHOICE=$(echo -e "Mode: $theme\nNight Light: $nl\nLayouts" | rofi -dmenu -p "Settings" -i) case "$CHOICE" in "Mode: "*) [ "$theme" == "dark" ] && set_val "theme" "light" || set_val "theme" "dark" apply_all ;; "Night Light: "*) if [ "$nl" == "on" ]; then set_val "nightlight" "off"; pkill wlsunset else set_val "nightlight" "on"; wlsunset -T 4500 & fi ;; "Layouts") L=$(echo -e "tile\nmonocle\nscroller\ntgmix\ngrid\ndeck\ncenter tile\nright tile\nvertical scroller\nvertical tile\nvertical grid\nvertical deck" | rofi -dmenu -p "Layout") case "$L" in "tile") set_layout "T" ;; "monocle") set_layout "M" ;; "scroller") set_layout "S" ;; "tgmix") set_layout "TG" ;; "grid") set_layout "G" ;; "deck") set_layout "K" ;; "center tile") set_layout "CT" ;; "right tile") set_layout "RT" ;; "vertical grid") set_layout "VG" ;; "vertical tile") set_layout "VT" ;; "vertical deck") set_layout "VK" ;; "vertical scroller") set_layout "VS" ;; esac ;; esac } init_settings case "$1" in wall) cmd_wall ;; settings) cmd_settings ;; apply) apply_all ;; *) echo "Usage: bee {wall|settings|apply}" ;; esac ''; in { home.packages = [ volume-control brightness-control mic-control beesettings ]; }