blob: f59da8928010c538c204e7c9365473b9a507d99f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/bin/sh
# Music module script for dwmblocks
truncate() {
echo "$1" | cut -c1-20
}
# Handle mouse events based on button clicks
case $BLOCK_BUTTON in
1) # Left click to pause/play
playerctl play-pause
pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;;
2) # Middle click to open the music player
# Replace `your-music-player` with your actual music player command
emacs-launcher "music" & ;;
3) # Right click to show notification
notify-send "🎵 Music Module
- Left click to play/pause.
- Middle click to open music player.
- Right click to show current track." ;;
4) # Scroll up to go back
playerctl previous
pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;;
5) # Scroll down to skip
playerctl next
pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;;
esac
# Get current track info
artist="$(playerctl metadata artist 2>/dev/null || echo "Unknown Artist")"
title="$(playerctl metadata title 2>/dev/null || echo "No Track")"
# Truncate artist and title to 15 characters
truncated_artist=$(truncate "$artist")
truncated_title=$(truncate "$title")
# Format the output as "artist - title"
current_track="$truncated_artist - $truncated_title"
# Print the current track
echo "$current_track"
|