{ pkgs, config, lib, ... }: 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\ncolor_type=scheme-tonal-spot" > "$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 color_type=$(get_val "color_type") local mode_flag="dark" [ "$theme" == "light" ] && mode_flag="light" matugen image "$wall" -m "$mode_flag" -t "$color_type" --source-color-index 0 2>/dev/null wallust -q -s run -p "''${mode_flag}16" "$wall" 2>/dev/null systemctl --user restart xdg-desktop-portal-gtk if [ "$mode_flag" = "dark" ]; then dconf write /org/gnome/desktop/interface/color-scheme "'prefer-light'" else dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'" fi dconf write /org/gnome/desktop/interface/color-scheme "'prefer-$mode_flag'" if [ -z "$WAYLAND_DISPLAY" ] && [ -n "$DISPLAY" ]; then xrdb -merge "$HOME/.Xresources" fi ${lib.optionalString (config.beeMods.terminal.default == "foot" || config.beeMods.terminal.default == "ghostty") '' [ -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 awww >/dev/null 2>&1; then awww 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 --no-fehbg --bg-fill "$FULL_PATH" fi apply_all fi } clr_type() { local types=( "scheme-tonal-spot" "scheme-content" "scheme-expressive" "scheme-fidelity" "scheme-fruit-salad" "scheme-monochrome" "scheme-neutral" "scheme-rainbow" "scheme-vibrant" ) local selection selection=$(printf "%s\n" "''${types[@]}" | rofi -dmenu -i -p "Coloscheme Types") if [[ -n "$selection" ]]; then set_val "color_type" "$selection" apply_all fi } cmd_layout() { declare -A layouts=( ["tile"]="T" ["monocle"]="M" ["scroller"]="S" ["tgmix"]="TG" ["grid"]="G" ["deck"]="K" ["center tile"]="CT" ["right tile"]="RT" ["vertical scroller"]="VS" ["vertical tile"]="VT" ["vertical grid"]="VG" ["vertical deck"]="VK" ) local selection selection=$(printf "%s\n" "''${!layouts[@]}" | sort | rofi -dmenu -i -p "Layout") if [[ -n "''${layouts[$selection]}" ]]; then set_layout "''${layouts[$selection]}" fi } cmd_settings() { local theme=$(get_val "theme") local nl=$(get_val "nightlight") local ct=$(get_val "color_type") local options=( "Mode: $theme" "Night Light: $nl" "Wallpaper" "Colorscheme Type: $ct" "Layouts" ) local choice choice=$(printf "%s\n" "''${options[@]}" | 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 ;; "Wallpaper") cmd_wall ;; "Colorscheme Type:"*) clr_type ;; "Layouts") cmd_layout ;; esac } init_settings case "$1" in wall) cmd_wall ;; settings) cmd_settings ;; layout) cmd_layout ;; apply) apply_all ;; *) echo "Usage: bee {wall|settings|apply}" ;; esac ''; in { home.packages = [ volume-control brightness-control mic-control beesettings ]; }