notifications for media controls

This commit is contained in:
Dmitri 2025-11-07 09:36:15 +01:00
parent 1b31f4dd4d
commit 31caf2c391
Signed by: kanopo
GPG Key ID: 759ADD40E3132AC7
4 changed files with 127 additions and 41 deletions

2
.zshrc
View File

@ -23,6 +23,8 @@ plug "romkatv/powerlevel10k"
# # nvm initialization # # nvm initialization
# source /usr/share/nvm/init-nvm.sh # source /usr/share/nvm/init-nvm.sh
XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:-sway}"
MOZ_ENABLE_WAYLAND=1
alias v="nvim" alias v="nvim"
alias conservation-on="sudo ectool chargecontrol normal 80 80" alias conservation-on="sudo ectool chargecontrol normal 80 80"

View File

@ -177,36 +177,15 @@ bindsym $mod+r mode "resize"
### Notifiche e Controlli Audio/Luminosità ### Notifiche e Controlli Audio/Luminosità
set $notification_time 1000 set $notification_time 1000
# Comandi per le notifiche (volume, mute, mic, luminosità) # Audio controls
set $audio_notification_cmd command -v notify-send >/dev/null && \ bindsym XF86AudioMute exec ~/.config/sway/scripts/notification-control.sh mute-toggle
VALUE=$(pactl get-sink-volume @DEFAULT_SINK@ | head -n 1 | awk '{print substr($5, 1, length($5)-1)}') && \ bindsym XF86AudioLowerVolume exec ~/.config/sway/scripts/notification-control.sh volume-down
notify-send -e -h string:x-canonical-private-synchronous:audio \ bindsym XF86AudioRaiseVolume exec ~/.config/sway/scripts/notification-control.sh volume-up
-h "int:value:$VALUE" -t $notification_time "Volume: ${VALUE}%" bindsym XF86AudioMicMute exec ~/.config/sway/scripts/notification-control.sh mic-mute-toggle
set $mute_notification_cmd command -v notify-send >/dev/null && \ # Brightness controls
VALUE=$(pactl get-sink-mute @DEFAULT_SINK@ | head -n 1 | awk '{print $2}') && \ bindsym XF86MonBrightnessDown exec ~/.config/sway/scripts/notification-control.sh brightness-down
notify-send -e -h string:x-canonical-private-synchronous:audio \ bindsym XF86MonBrightnessUp exec ~/.config/sway/scripts/notification-control.sh brightness-up
-h "string:x-canonical-private-synchronous:audio" -t $notification_time "Mute: ${VALUE}"
set $mute_mic_notification_cmd command -v notify-send >/dev/null && \
VALUE=$(pactl get-source-mute @DEFAULT_SOURCE@ | head -n 1 | awk '{print $2}') && \
notify-send -e -h string:x-canonical-private-synchronous:audio \
-h "string:x-canonical-private-synchronous:audio" -t $notification_time "Mic Mute: ${VALUE}"
set $brightness_notification_cmd command -v notify-send >/dev/null && \
VALUE=$(brightnessctl get) && \
MAX=255 && \
PERCENT=$((VALUE * 100 / MAX)) && \
notify-send -e -h string:x-canonical-private-synchronous:brightness \
-h "int:value:$PERCENT" -t $notification_time "Brightness: ${PERCENT}%"
# Key bindings per audio e luminosità
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle; exec $mute_notification_cmd
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% && $audio_notification_cmd
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% && $audio_notification_cmd
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle && $mute_mic_notification_cmd
bindsym XF86MonBrightnessDown exec brightnessctl s 10%- && $brightness_notification_cmd
bindsym XF86MonBrightnessUp exec brightnessctl s 10%+ && $brightness_notification_cmd
# Controlli multimediali # Controlli multimediali
bindsym XF86AudioPlay exec playerctl play-pause bindsym XF86AudioPlay exec playerctl play-pause
@ -214,18 +193,24 @@ bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous bindsym XF86AudioPrev exec playerctl previous
### Screenshot e Registrazione Schermo ### Screenshot e Registrazione Schermo
bindsym Print exec grimshot --notify copy output bindsym Print exec grimshot --notify copy output && \
bindsym $mod+Print exec grimshot --notify copy area notify-send -u normal "📸 Screenshot" "Full screen copied to clipboard"
bindsym $mod+P exec grimshot --notify copy output
bindsym $mod+Shift+P exec grimshot --notify copy area
bindsym $mod+XF86AudioMedia exec --no-startup-id \ # Screenshot selected area
(pgrep -x wf-recorder > /dev/null && killall -s SIGINT wf-recorder && notify-send "Recording Stopped") || \ bindsym $mod+Print exec grimshot --notify copy area && \
(notify-send "Recording Started + Audio." && wf-recorder --audio --file ~/Videos/$(date +'%Y-%m-%d-%H-%M-%S').mp4) notify-send -u normal "📸 Screenshot" "Selected area copied to clipboard"
bindsym XF86AudioMedia exec --no-startup-id \ # Alternative bindings
(pgrep -x wf-recorder > /dev/null && killall -s SIGINT wf-recorder && notify-send "Recording Stopped") || \ bindsym $mod+P exec grimshot --notify copy output && \
(notify-send "Recording Started" && wf-recorder --file ~/Videos/$(date +'%Y-%m-%d-%H-%M-%S').mp4) notify-send -u normal "📸 Screenshot" "Full screen copied to clipboard"
bindsym $mod+Shift+P exec grimshot --notify copy area && \
notify-send -u normal "📸 Screenshot" "Selected area copied to clipboard"
# this one includes audio track in the recording
bindsym $mod+XF86AudioMedia exec ~/.config/sway/scripts/screen-recording.sh audio
# this one not
bindsym XF86AudioMedia exec ~/.config/sway/scripts/screen-recording.sh
### Modalità per azioni di sistema (lock, logout, reboot, suspend, shutdown) ### Modalità per azioni di sistema (lock, logout, reboot, suspend, shutdown)
set $mode_system "What to do? (l) lock, (e) logout, (r) reboot, (Shift+s) shutdown" set $mode_system "What to do? (l) lock, (e) logout, (r) reboot, (Shift+s) shutdown"
@ -248,8 +233,8 @@ bar {
### Borders e Gaps ### Borders e Gaps
default_border pixel default_border pixel
smart_gaps on smart_gaps on
gaps outer 3 gaps outer 2
gaps inner 5 gaps inner 3
# Impostazioni dei colori per il focus delle finestre # Impostazioni dei colori per il focus delle finestre
client.focused $gruvbox_orange $gruvbox_orange $gruvbox_bg_dark $gruvbox_orange client.focused $gruvbox_orange $gruvbox_orange $gruvbox_bg_dark $gruvbox_orange

View File

@ -0,0 +1,69 @@
#!/usr/bin/env bash
ACTION="$1"
NOTIFICATION_TIME=1000
case "$ACTION" in
volume-up)
pactl set-sink-volume @DEFAULT_SINK@ +5%
VALUE=$(pactl get-sink-volume @DEFAULT_SINK@ | head -n 1 | awk '{print substr($5, 1, length($5)-1)}')
notify-send -e -h string:x-canonical-private-synchronous:audio \
-h "int:value:$VALUE" -t $NOTIFICATION_TIME "🔊 Volume" "${VALUE}%"
;;
volume-down)
pactl set-sink-volume @DEFAULT_SINK@ -5%
VALUE=$(pactl get-sink-volume @DEFAULT_SINK@ | head -n 1 | awk '{print substr($5, 1, length($5)-1)}')
notify-send -e -h string:x-canonical-private-synchronous:audio \
-h "int:value:$VALUE" -t $NOTIFICATION_TIME "🔉 Volume" "${VALUE}%"
;;
mute-toggle)
pactl set-sink-mute @DEFAULT_SINK@ toggle
MUTED=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}')
if [ "$MUTED" = "yes" ]; then
notify-send -e -h string:x-canonical-private-synchronous:audio \
-t $NOTIFICATION_TIME "🔇 Audio Muted" "Output muted"
else
notify-send -e -h string:x-canonical-private-synchronous:audio \
-t $NOTIFICATION_TIME "🔊 Audio Unmuted" "Output active"
fi
;;
mic-mute-toggle)
pactl set-source-mute @DEFAULT_SOURCE@ toggle
MUTED=$(pactl get-source-mute @DEFAULT_SOURCE@ | awk '{print $2}')
if [ "$MUTED" = "yes" ]; then
notify-send -e -h string:x-canonical-private-synchronous:audio \
-t $NOTIFICATION_TIME "🎤 Microphone Muted" "Mic muted"
else
notify-send -e -h string:x-canonical-private-synchronous:audio \
-t $NOTIFICATION_TIME "🎤 Microphone Active" "Mic unmuted"
fi
;;
brightness-up)
brightnessctl s 10%+
# Get current and max brightness values
CURRENT=$(brightnessctl get)
MAX=$(brightnessctl max)
PERCENT=$((CURRENT * 100 / MAX))
notify-send -e -h string:x-canonical-private-synchronous:brightness \
-h "int:value:$PERCENT" -t $NOTIFICATION_TIME "☀️ Brightness" "${PERCENT}%"
;;
brightness-down)
brightnessctl s 10%-
# Get current and max brightness values
CURRENT=$(brightnessctl get)
MAX=$(brightnessctl max)
PERCENT=$((CURRENT * 100 / MAX))
notify-send -e -h string:x-canonical-private-synchronous:brightness \
-h "int:value:$PERCENT" -t $NOTIFICATION_TIME "🔅 Brightness" "${PERCENT}%"
;;
*)
echo "Usage: $0 {volume-up|volume-down|mute-toggle|mic-mute-toggle|brightness-up|brightness-down}"
exit 1
;;
esac

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
RECORD_DIR="$HOME/Videos"
TIMESTAMP=$(date +'%Y-%m-%d-%H-%M-%S')
AUDIO_FLAG="$1"
# Create directory if it doesn't exist
if [ ! -d "$RECORD_DIR" ]; then
mkdir -p "$RECORD_DIR"
notify-send -u low "📁 Directory Created" "$RECORD_DIR"
fi
if pgrep -x wf-recorder > /dev/null; then
killall -s SIGINT wf-recorder
notify-send -u normal "🛑 Recording Stopped" "Saved to $RECORD_DIR/"
else
if [ "$AUDIO_FLAG" = "audio" ]; then
notify-send -u normal "🔴 Recording Started" "With audio enabled"
wf-recorder --audio --file "$RECORD_DIR/${TIMESTAMP}.mp4"
else
notify-send -u normal "🔴 Recording Started" "Video only"
wf-recorder --file "$RECORD_DIR/${TIMESTAMP}.mp4"
fi
if [ $? -eq 0 ]; then
notify-send -u normal "✅ Recording Complete" "Saved as ${TIMESTAMP}.mp4"
else
notify-send -u critical "❌ Recording Failed" "Check your configuration"
fi
fi