commit 897182da1d5ce802e3140b5d26fc5c2aca7d80e8
parent 1dd6b7ecf12a5e04de3f6cafad6ba4b241f1a75f
Author: regexghost <regexghost@protonmail.com>
Date: Thu, 7 May 2026 15:19:14 +0100
music.sh and xinitrc
Diffstat:
2 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/dotfiles/.xinitrc b/dotfiles/.xinitrc
@@ -0,0 +1,12 @@
+# Notifications
+dunst & disown
+
+# Increase key rate (delay = 250, repeat rate = 40)
+xset r rate 250 40
+
+# No screen timeout/auto sleep
+xset s off
+xset dpms 0 0 0
+
+# Window manger
+exec jwm
diff --git a/panel-scripts/music.sh b/panel-scripts/music.sh
@@ -0,0 +1,65 @@
+#!/usr/bin/env sh
+
+# Music playing script
+
+MUSIC_DIR="$HOME/Music"
+FAVOURITES_DIR="$MUSIC_DIR/Favourites"
+
+# Technically these first 4 are unnecessary, could just bind directly to the command
+# but I like it all being in one file
+if [ "$1" = "--toggle-pause" ]; then
+ mocp --toggle-pause
+ exit
+elif [ "$1" = "--quit" ]; then
+ mocp --stop
+ exit
+elif [ "$1" = "--next" ]; then
+ mocp --next
+ exit
+elif [ "$1" = "--previous" ]; then
+ mocp --previous
+ exit
+elif [ "$1" = "--favourite" ]; then
+ song="$(mocp -i | grep "File:" | sed 's/File: //g')"
+ echo "$song" | grep -q "CurrentPlaylist/" && exit
+ favourite_path="$(echo "$song" | sed "s|$MUSIC_DIR/||g")"
+ favourite_dir="$(dirname "$favourite_path")"
+ mkdir -p "$FAVOURITES_DIR/${favourite_dir}"
+ ln -sf "$song" "$FAVOURITES_DIR/${favourite_path}"
+ notify-send "Added to favourites"
+ exit
+elif [ "$1" = "--get-song" ]; then
+ song="$(mocp -i 2> /dev/null | awk '/^Title:/ {S1 = ""; printf $0}')"
+ [ "$song" = "" ] && echo "None" && exit
+ echo "$song"
+ exit
+fi
+
+# Start mocp if not running, and set mode to shuffle
+if ! pgrep mocp; then
+ mocp -S
+ mocp -t shuffle
+fi
+
+# If mocp is currently playing music, just notify-send the song title
+if ! mocp -i | grep -q "State: STOP"; then
+ notify-send "$(mocp -i | grep "Title: " | sed 's/Title: //g')"
+ exit
+fi
+
+# Ask for playlist
+playlist="$(ls "$MUSIC_DIR" | sed 's/\([A-Z][a-z]\)/ \1/g' | sed 's/\([a-z]\)\([0-9]\)/\1 \2/g' | sed 's/^ //g' | dmenu -p "Select Playlist:" -l 10)"
+playlist_path="$MUSIC_DIR/$(echo "$playlist" | sed 's/ //g')"
+
+# Check for sub playlists
+if find "$playlist_path" -mindepth 1 -type d | grep -q ""; then
+ playlist="$(ls "$playlist_path" | sed 's/\([A-Z][a-z]\)/ \1/g' | sed 's/\([a-z]\)\([0-9]\)/\1 \2/g' | sed 's/^ //g' | awk 'BEGIN {RS = ""} {print "All Songs\n"$0}' | dmenu -p "Select Playlist:" -l 10)"
+ # If all songs, don't change playlist path
+ if ! [ "$playlist" = "All Songs" ]; then
+ playlist_path="$playlist_path/$(echo "$playlist" | sed 's/ //g')"
+ fi
+fi
+
+mocp --clear
+mocp --append "$playlist_path"
+mocp --play