{ pkgs, config }: rec { terminal_with_tmux = pkgs.writeShellScript "terminal_with_tmux" '' TERM="${config.beeMods.terminal.default}" SESSION="_main" if pgrep -x "$TERM" >/dev/null; then if tmux ls &>/dev/null; then tmux neww exit 0 else exec $TERM -e tmux new -s $SESSION fi else if tmux ls &>/dev/null; then exec $TERM -e tmux attach else exec $TERM -e tmux new -s $SESSION fi fi ''; defaultTerm = config.beeMods.terminal.default; terminal = if defaultTerm == "foot" then "footclient" else if defaultTerm == "ghostty" then "ghostty +new-window || ghostty" else "alacritty msg create-window || alacritty"; dotfiles = pkgs.writeShellScriptBin "dotfiles" '' case "$1" in cd) cd "$HOME/.config/beeSystems" ;; edit) "$EDITOR" "$HOME/.config/beeSystems" ;; flake) case "$2" in update) ( cd "$HOME/.config/beeSystems" || exit 1 nix flake update ) ;; esac ;; esac ''; update_gtk_theme = pkgs.writeShellScript "update_gtk_theme" '' if [ "$1" = "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-$1'" systemctl --user restart xdg-desktop-portal-gtk ''; volume = pkgs.writeShellScript "volume" '' TAG="audio-volume" case $1 in up) wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+ ;; down) wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- ;; toggle) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;; esac status=$(wpctl get-volume @DEFAULT_AUDIO_SINK@) vol=$(awk '{print int($2 * 100)}' <<< "$status") case "$status" in *MUTED*) dunstify -a "Volume" -u low \ -h string:x-canonical-private-synchronous:$TAG \ "Volume: Muted" ;; *) dunstify -a "Volume" -u low \ -h string:x-canonical-private-synchronous:$TAG \ -h int:value:"$vol" \ "Volume: $vol%" ;; esac ''; micToggle = pkgs.writeShellScript "micToggle" '' TAG="audio-mic" wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle status=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@) if [[ "$status" == *MUTED* ]]; then dunstify -a "Microphone" -u low \ -h string:x-canonical-private-synchronous:$TAG \ "Microphone: Muted" else dunstify -a "Microphone" -u low \ -h string:x-canonical-private-synchronous:$TAG \ "Microphone: On" fi ''; brightness = pkgs.writeShellScript "brightness" '' TAG="screen-brightness" case "$1" in up) brightnessctl set +5% > /dev/null ;; down) brightnessctl set 5%- > /dev/null ;; esac current=$(brightnessctl -m | cut -d, -f4 | tr -d '%') dunstify -a "Brightness" -u low \ -h string:x-canonical-private-synchronous:$TAG \ -h int:value:"$current" \ "Brightness: $current%" ''; screenshot = pkgs.writeShellScript "screenshot" '' case $1 in full) ${pkgs.grim}/bin/grim - | wl-copy ;; selection) GEOM=$(${pkgs.slurp}/bin/slurp) || exit ${pkgs.grim}/bin/grim -g "$GEOM" - | wl-copy ;; window) ${pkgs.grim}/bin/grim -g "$(mmsg -x | awk ' / x / {x=$3} / y / {y=$3} / width / {w=$3} / height / {h=$3} END {print x "," y " " w "x" h} ')" - | wl-copy ;; esac ''; dostuff = pkgs.writeShellScript "dostuff" '' exec 2>/dev/null : "''${CONFIG_FILE:=$HOME/.config/beestuff/conf}" : "''${WALL_DIR:=$HOME/Pictures/Wallpapers}" : "''${THUMB_DIR:=$HOME/.cache/beestuff/thumbnails}" init_settings() { [ -f "$CONFIG_FILE" ] && return 0 local config_dir config_dir=$(dirname -- "$CONFIG_FILE") mkdir -p -- "$config_dir" cat > "$CONFIG_FILE" </dev/null 2>&1; then magick "$img" \ -resize 400x300^ \ -gravity center \ -extent 400x300 \ "$thumb" elif command -v convert >/dev/null 2>&1; then convert "$img" \ -resize 400x300^ \ -gravity center \ -extent 400x300 \ "$thumb" elif command -v ffmpeg >/dev/null 2>&1; then ffmpeg -hide_banner -loglevel error \ -i "$img" \ -vf "scale=400:300:force_original_aspect_ratio=cover,crop=400:300" \ -frames:v 1 \ "$thumb" else printf '%s' "$img" return 0 fi [ -f "$thumb" ] || thumb="$img" printf '%s' "$thumb" } list_walls() { local wall for wall in "$WALL_DIR"/*.{jpg,jpeg,png,webp}; do [ -f "$wall" ] || continue printf '%s\0icon\x1f%s\n' \ "''${wall##*/}" \ "$(ensure_thumb "$wall")" done } apply_all() { local theme=$(get_val "theme") local wall=$(get_val "wallpaper") local color_type=$(get_val "color_type") local mode_flag="dark" mode_flag="dark" [ "$theme" = "light" ] && mode_flag="light" matugen image "$wall" \ -r lanczos3 \ --continue-on-error \ -m "$mode_flag" \ -t "$color_type" \ --source-color-index 0 "${update_gtk_theme}" "$mode_flag" if [ -z "$WAYLAND_DISPLAY" ] && [ -n "$DISPLAY" ]; then xrdb -merge "$HOME/.Xresources" fi local seq_file="$HOME/.local/share/bee/sequences" [ -f "$seq_file" ] && sh "$seq_file" } cmd_wall() { local selected full_path 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: 4; lines: 2; }' \ -theme-str 'window { width: 50%; }' ) [ -n "$selected" ] || return 0 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 } clr_type() { local schemes selection schemes=( "scheme-tonal-spot" "scheme-content" "scheme-expressive" "scheme-fidelity" "scheme-fruit-salad" "scheme-monochrome" "scheme-neutral" "scheme-rainbow" "scheme-vibrant" ) selection=$( printf '%s\n' "''${schemes[@]}" | rofi -dmenu -i -p "Colorscheme Types" ) [ -n "$selection" ] || return 0 set_val "color_type" "$selection" apply_all } cmd_layout() { local layouts selection layouts=( tile monocle scroller fair dwindle grid deck center_tile right_tile vertical_scroller vertical_tile vertical_grid vertical_fair vertical_deck ) selection=$( printf '%s\n' "''${layouts[@]}" | rofi -dmenu -i -p "Layout" ) [ -n "$selection" ] || return 0 set_layout "$selection" } cmd_settings() { local theme nl ct choice theme=$(get_val "theme") nl=$(get_val "nightlight") ct=$(get_val "color_type") choice=$( printf '%s\n' \ "Mode: $theme" \ "Night Light: $nl" \ "Wallpaper" \ "Colorscheme Type: $ct" \ "Layouts" | rofi -dmenu -p "Settings" -i ) case "$choice" in "Mode: "*) if [ "$theme" = "dark" ]; then set_val "theme" "light" else set_val "theme" "dark" fi apply_all ;; "Night Light: "*) if [ "$nl" = "on" ]; then set_val "nightlight" "off" pkill wlsunset else set_val "nightlight" "on" exec 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 ;; *) printf '%s\n' "Usage: bee {wall|settings|layout|apply}" ;; esac ''; }