diff --git a/.bin/sh/dunstaudio.sh b/.bin/sh/dunstaudio.sh new file mode 100755 index 0000000..25b3041 --- /dev/null +++ b/.bin/sh/dunstaudio.sh @@ -0,0 +1,168 @@ +#!/bin/bash + +# See README.md for usage instructions +volume_step=1 +brightness_step=5 +max_volume=100 +notification_timeout=1500 +download_album_art=true +show_album_art=true +show_music_in_volume_indicator=true + +# Uses regex to get volume from pactl +function get_volume { + pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '[0-9]{1,3}(?=%)' | head -1 +} + +# Uses regex to get mute status from pactl +function get_mute { + pactl get-sink-mute @DEFAULT_SINK@ | grep -Po '(?<=Mute: )(yes|no)' +} + +# Uses regex to get brightness from xbacklight +function get_brightness { + sudo light | grep -Po '[0-9]{1,3}' | head -n 1 +} + +# Returns a mute icon, a volume-low icon, or a volume-high icon, depending on the volume +function get_volume_icon { + volume=$(get_volume) + mute=$(get_mute) + if [ "$volume" -eq 0 ] || [ "$mute" == "yes" ] ; then + volume_icon="󰝟" + elif [ "$volume" -lt 50 ]; then + volume_icon="󰖀" + else + volume_icon="󰕾" + fi +} + +# Always returns the same icon - I couldn't get the brightness-low icon to work with fontawesome +function get_brightness_icon { + brightness_icon="" +} + +function get_album_art { + url=$(playerctl -f "{{mpris:artUrl}}" metadata) + if [[ $url == "file://"* ]]; then + album_art="${url/file:\/\//}" + elif [[ $url == "http://"* ]] && [[ $download_album_art == "true" ]]; then + # Identify filename from URL + filename="$(echo $url | sed "s/.*\///")" + + # Download file to /tmp if it doesn't exist + if [ ! -f "/tmp/$filename" ]; then + wget -O "/tmp/$filename" "$url" + fi + + album_art="/tmp/$filename" + elif [[ $url == "https://"* ]] && [[ $download_album_art == "true" ]]; then + # Identify filename from URL + filename="$(echo $url | sed "s/.*\///")" + + # Download file to /tmp if it doesn't exist + if [ ! -f "/tmp/$filename" ]; then + wget -O "/tmp/$filename" "$url" + fi + + album_art="/tmp/$filename" + else + album_art="" + fi +} + +# Displays a volume notification +function show_volume_notif { + volume=$(get_mute) + get_volume_icon + + if [[ $show_music_in_volume_indicator == "true" ]]; then + current_song=$(playerctl -f "{{title}} - {{artist}}" metadata) + + if [[ $show_album_art == "true" ]]; then + get_album_art + fi + + notify-send -t $notification_timeout -h string:x-dunst-stack-tag:volume_notif -h int:value:$volume -i "$album_art" "$volume_icon $volume%" "$current_song" + else + notify-send -t $notification_timeout -h string:x-dunst-stack-tag:volume_notif -h int:value:$volume "$volume_icon $volume%" + fi +} + +# Displays a music notification +function show_music_notif { + song_title=$(playerctl -f "{{title}}" metadata) + song_artist=$(playerctl -f "{{artist}}" metadata) + song_album=$(playerctl -f "{{album}}" metadata) + + if [[ $show_album_art == "true" ]]; then + get_album_art + fi + + notify-send -t $notification_timeout -h string:x-dunst-stack-tag:music_notif -i "$album_art" "$song_title" "$song_artist - $song_album" +} + +# Displays a brightness notification using dunstify +function show_brightness_notif { + brightness=$(get_brightness) + echo $brightness + get_brightness_icon + notify-send -t $notification_timeout -h string:x-dunst-stack-tag:brightness_notif -h int:value:$brightness "$brightness_icon $brightness%" +} + +# Main function - Takes user input, "volume_up", "volume_down", "brightness_up", or "brightness_down" +case $1 in + volume_up) + # Unmutes and increases volume, then displays the notification + pactl set-sink-mute @DEFAULT_SINK@ 0 + volume=$(get_volume) + if [ $(( "$volume" + "$volume_step" )) -gt $max_volume ]; then + pactl set-sink-volume @DEFAULT_SINK@ $max_volume% + else + pactl set-sink-volume @DEFAULT_SINK@ +$volume_step% + fi + show_volume_notif + ;; + + volume_down) + # Raises volume and displays the notification + pactl set-sink-volume @DEFAULT_SINK@ -$volume_step% + show_volume_notif + ;; + + volume_mute) + # Toggles mute and displays the notification + pactl set-sink-mute @DEFAULT_SINK@ toggle + show_volume_notif + ;; + + brightness_up) + # Increases brightness and displays the notification + sudo light -A $brightness_step + show_brightness_notif + ;; + + brightness_down) + # Decreases brightness and displays the notification + sudo light -U $brightness_step + show_brightness_notif + ;; + + next_track) + # Skips to the next song and displays the notification + playerctl next + sleep 0.5 && show_music_notif + ;; + + prev_track) + # Skips to the previous song and displays the notification + playerctl previous + sleep 0.5 && show_music_notif + ;; + + play_pause) + playerctl play-pause + show_music_notif + # Pauses/resumes playback and displays the notification + ;; +esac diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc new file mode 100644 index 0000000..8bcfef0 --- /dev/null +++ b/.config/dunst/dunstrc @@ -0,0 +1,84 @@ +# See dunst(5) for all configuration options + +[global] + monitor = 0 + follow = mouse + width = 400 + height = (0,400) + origin = top-right + offset = (15,15) + scale = 0 + notification_limit = 0 + progress_bar = true + progress_bar_height = 10 + progress_bar_frame_width = 1 + progress_bar_min_width = 150 + progress_bar_max_width = 400 + indicate_hidden = yes + transparency = 15 + separator_height = 1 + padding = 8 + horizontal_padding = 10 + text_icon_padding = 0 + frame_width = 1 + frame_color = "#44475a" + highlight = "#50fa7b" + separator_color = frame + sort = yes + idle_threshold = 120 + line_height = 0 + font = Droid Sans Regular 12 + markup = full + format = "%s \n%b" + alignment = left + vertical_alignment = center + show_age_threshold = 60 + ellipsize = middle + ignore_newline = no + stack_duplicates = true + hide_duplicate_count = false + show_indicators = yes + icon_position = left + min_icon_size = 64 + max_icon_size = 64 + icon_path = /usr/share/icons/Papirus-Dark/16x16/status/:/usr/share/icons/Papirus-Dark/16x16/devices + sticky_history = yes + history_length = 20 + dmenu = /usr/bin/rofi -dmenu -p dunst: + browser = /usr/bin/firefox -new-tab + always_run_script = true + title = Dunst + class = Dunst + corner_radius = 6 + ignore_dbusclose = false + force_xwayland = false + force_xinerama = false + mouse_middle_click = close_current + mouse_left_click = do_action, close_current + mouse_right_click = close_all + +[experimental] + per_monitor_dpi = false + +[urgency_low] + background = "#282a36" + foreground = "#6272a4" + timeout = 10 + +[urgency_normal] + background = "#282a36" + foreground = "#bd93f9" + timeout = 10 + +[urgency_critical] + background = "#ff5555" + foreground = "#f8f8f2" + frame_color = "#ff5555" + timeout = 0 + +[fullscreen_delay_everything] + fullscreen = delay + +[fullscreen_show_critical] + msg_urgency = critical + fullscreen = show diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf index 3d93f11..c4bd702 100644 --- a/.config/hypr/hyprland.conf +++ b/.config/hypr/hyprland.conf @@ -55,8 +55,8 @@ exec-once = udiskie -t & exec-once = /usr/lib/polkit-kde-authentication-agent-1 exec-once = sleep 1; blueman-applet exec-once = hyprpaper -exec-once = swaync -exec-once = [workspace special:music silent] sleep 1; supersonic-desktop +exec-once = [workspace special:music silent] supersonic-desktop +exec-once = dunst exec-once = waybar exec-once = hypridle exec-once = hyprctl setcursor Dracula-cursors 24 @@ -222,7 +222,7 @@ bind = $mainMod, F, fullscreen bind = $mainMod, C, exec, galculator bind = $mainMod CTRL, T, exec, steam bind = $mainMod CTRL, Y, exec, heroic -bind = $mainMod, N, exec, exec swaync-client -t -sw +bind = $mainMod, N, exec, dunstctl context bind = $mainMod CTRL, U, exec, [workspace special:scratchpad silent] signal-desktop --ozone-platform-hint=auto --enable-features=UseOzonePlatform,WaylandWindowDecorations bind = $mainMod CTRL, P, exec, [workspace special:password silent] keepassxc bind = $mainMod CTRL, M, exec, [workspace special:music silent] sleep 1; supersonic-desktop @@ -256,15 +256,20 @@ bind = ALT, SPACE, focuscurrentorlast # Media keys -bind = ,XF86AudioPlay,exec,playerctl play-pause -bind = ,XF86AudioPause,exec,playerctl pause +bind = ,XF86AudioPlayPause,exec,~/.bin/sh/dunstaudio.sh play_pause +bind = ,XF86AudioPlay,exec,~/.bin/sh/dunstaudio.sh play_pause +bind = ,XF86AudioPause,exec,~/.bin/sh/dunstaudio.sh play_pause bind = ,XF86AudioStop,exec,playerctl stop -bind = ,XF86AudioNext,exec,playerctl next -bind = ,XF86AudioPrev,exec,playerctl previous -bind = ,XF86AudioRaiseVolume,exec,wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ -bind = ,XF86AudioLowerVolume,exec,wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- -bind = ,XF86AudioMute,exec,pactl set-sink-mute @DEFAULT_SINK@ toggle +bind = ,XF86AudioNext,exec,~/.bin/sh/dunstaudio.sh next_track +bind = ,XF86AudioPrev,exec,~/.bin/sh/dunstaudio.sh prev_track +bind = ,XF86AudioRaiseVolume,exec,~/.bin/sh/dunstaudio.sh volume_up +bind = ,XF86AudioLowerVolume,exec,~/.bin/sh/dunstaudio.sh volume_down +bind = ,XF86AudioMute,exec,~/.bin/sh/dunstaudio.sh volume_mute +# Brightness keys + +bind = ,XF86MonBrightnessUp,exec,~/.bin/sh/dunstaudio.sh brightness_up +bind = ,XF86MonBrightnessDown,exec,~/.bin/sh/dunstaudio.sh brightness_down # Move focus with Mod + arrow keys @@ -374,6 +379,7 @@ bind = ,Print,exec,grim -g "$(slurp)" - | swappy -f - # Environment management +bind = $mainMod Shift, n, exec, killall dunst || exec dunst bind = $mainMod Shift, w, exec, killall waybar || exec waybar bind = $mainMod Shift, h, exec, killall hypridle || exec hypridle diff --git a/.config/rofi/config.rasi b/.config/rofi/config.rasi index 8607d07..4676d5d 100644 --- a/.config/rofi/config.rasi +++ b/.config/rofi/config.rasi @@ -4,6 +4,7 @@ configuration { show-icons: true; display-drun: ""; disable-history: false; + modi: "window,drun,run,ssh,filebrowser,keys"; } * { diff --git a/.config/supersonic/themes/dracula.toml b/.config/supersonic/themes/dracula.toml index 380f66a..1287c43 100644 --- a/.config/supersonic/themes/dracula.toml +++ b/.config/supersonic/themes/dracula.toml @@ -10,7 +10,7 @@ InputBackground = "#44475A" InputBorder = "#44475A" MenuBackground = "#282A36" OverlayBackground = "#282A36" -Hyperlink = "#BD93F9" +Hyperlink = "#50FA7B" Pressed = "#44475A" ListHeader = "#1E1F29" PageHeader = "#1E1F29" diff --git a/.config/waybar/config b/.config/waybar/config index 3104e96..0c73e1c 100644 --- a/.config/waybar/config +++ b/.config/waybar/config @@ -54,6 +54,9 @@ "tooltip-format": "󰠃 {artist}:  {title} (󰀥 {album})", "interval": 1, "album-len": 0, + "on-click": "exec ~/.bin/sh/dunstaudio.sh play_pause", + "on-click-right": "exec ~/.bin/sh/dunstaudio.sh next_track", + "on-click-middle": "exec ~/.bin/sh/dunstaudio.sh prev_track", "player-icons": { "default": "", "mpv": "" @@ -242,7 +245,9 @@ "car": "", "default": ["", "󰖀", "󰕾", ""] }, - "on-click": "pavucontrol" + "on-click": "pavucontrol", + "on-scroll-up": "exec ~/.bin/sh/dunstaudio.sh volume_up", + "on-scroll-down": "exec ~/.bin/sh/dunstaudio.sh volume_down" }, "bluetooth": { "format": " {status}", diff --git a/README.md b/README.md index b916d52..7e1f785 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ I use the [Dracula theme](https://draculatheme.com/), following their [color pal * Networking: [NetworkManager](https://networkmanager.dev/) * Wayland Compositor: [Hyprland](https://github.com/hyprwm/Hyprland) * Bar: [Waybar](https://github.com/Alexays/Waybar) -* Notifications: [SwayNotificationCenter](https://github.com/ErikReider/SwayNotificationCenter) +* Notifications: [Dunst](https://dunst-project.org) * Launcher: [Wofi](https://hg.sr.ht/~scoopta/wofi) * Menu Editor: [alacarte](https://gitlab.gnome.org/GNOME/alacarte) * File Manager: [nnn](https://github.com/jarun/nnn) @@ -98,5 +98,6 @@ A lot of the code was modified or borrowed from others that I will attempt to li * MrRoy's swaync [style.css](https://gist.github.com/MrRoy/3a4a0b1462921e78bf667e1b36697268) and his [config.json](https://gist.github.com/MrRoy/40f103bc34f3a58699e218c3d06d1a43). * Chick2D's [neofetch-themes](https://github.com/Chick2D/neofetch-themes) repository. * MrVivekRajan's [themes for Hyprlock](https://github.com/MrVivekRajan/Hyprlock-Styles), which I used as base for mine. +* Nicholas Anand's [i3-volume-brightness-indicator ](https://gitlab.com/Nmoleo/i3-volume-brightness-indicator/-/tree/main), whose awesome script is powering my notifications with dunst. If I'm missing anybody else, just open up a MR.