From 7ad4fd8a46fc09401d98c416777090defb431110 Mon Sep 17 00:00:00 2001 From: denode Date: Mon, 16 Mar 2026 13:58:03 +0100 Subject: [PATCH] added scripts --- README.md | 3 +- files/{ => scripts}/battery.sh | 0 files/scripts/music-notify | 72 +++++++++++++++++++++++++++++++ files/{ => scripts}/power.sh | 0 files/{ => scripts}/song.sh | 0 files/{ => scripts}/volume-osd.sh | 0 files/scripts/wallpaper-picker | 39 +++++++++++++++++ files/wallpaper-restore.sh | 2 +- 8 files changed, 114 insertions(+), 2 deletions(-) rename files/{ => scripts}/battery.sh (100%) create mode 100755 files/scripts/music-notify rename files/{ => scripts}/power.sh (100%) rename files/{ => scripts}/song.sh (100%) rename files/{ => scripts}/volume-osd.sh (100%) create mode 100755 files/scripts/wallpaper-picker diff --git a/README.md b/README.md index ec40f9a..2d41e76 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # arch-setup - +# install these applications +yay -S firefox hyprland waybar awww wofi rofi thunderbird onlyoffice-bin signal telegram code yazi vlc neovim dolphin diff --git a/files/battery.sh b/files/scripts/battery.sh similarity index 100% rename from files/battery.sh rename to files/scripts/battery.sh diff --git a/files/scripts/music-notify b/files/scripts/music-notify new file mode 100755 index 0000000..83b08df --- /dev/null +++ b/files/scripts/music-notify @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +import subprocess, threading, urllib.request +import dbus, dbus.service, dbus.mainloop.glib +from gi.repository import GLib + +class MusicNotifier: + def __init__(self): + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + bus = dbus.SessionBus() + obj = bus.get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") + self.iface = dbus.Interface(obj, "org.freedesktop.Notifications") + self.notif_id = dbus.UInt32(0) + + bus.add_signal_receiver( + self.on_action, + dbus_interface="org.freedesktop.Notifications", + signal_name="ActionInvoked" + ) + + def get_art(self, url): + if not url: + return "" + try: + if url.startswith("file://"): + return url[7:] + path = "/tmp/music_art.jpg" + urllib.request.urlretrieve(url, path) + return path + except: + return "" + + def notify(self, artist, title, art_url, status): + art = self.get_art(art_url) + play_label = "⏸ Pause" if status == "Playing" else "▶ Play" + actions = ["prev", "⏮ Zurück", "toggle", play_label, "next", "⏭ Weiter"] + hints = {"image-path": dbus.String(art)} if art else {} + + self.notif_id = self.iface.Notify( + "music", self.notif_id, art, + title, artist, + actions, hints, 0 + ) + + def on_action(self, notif_id, action): + if notif_id != self.notif_id: + return + cmds = {"prev": "previous", "toggle": "play-pause", "next": "next"} + if action in cmds: + subprocess.run(["playerctl", cmds[action]]) + + def monitor(self): + proc = subprocess.Popen( + ["playerctl", "--follow", "metadata", "--format", + "{{artist}}||{{title}}||{{mpris:artUrl}}||{{status}}"], + stdout=subprocess.PIPE, text=True + ) + prev = "" + for line in proc.stdout: + parts = line.strip().split("||") + if len(parts) != 4: + continue + artist, title, art_url, status = parts + if title != prev: + prev = title + self.notify(artist, title, art_url, status) + + def run(self): + threading.Thread(target=self.monitor, daemon=True).start() + GLib.MainLoop().run() + +if __name__ == "__main__": + MusicNotifier().run() diff --git a/files/power.sh b/files/scripts/power.sh similarity index 100% rename from files/power.sh rename to files/scripts/power.sh diff --git a/files/song.sh b/files/scripts/song.sh similarity index 100% rename from files/song.sh rename to files/scripts/song.sh diff --git a/files/volume-osd.sh b/files/scripts/volume-osd.sh similarity index 100% rename from files/volume-osd.sh rename to files/scripts/volume-osd.sh diff --git a/files/scripts/wallpaper-picker b/files/scripts/wallpaper-picker new file mode 100755 index 0000000..8483dcf --- /dev/null +++ b/files/scripts/wallpaper-picker @@ -0,0 +1,39 @@ + +#!/bin/bash +# wallpaper-picker.sh + +WALLPAPER_DIR="$HOME/Pictures/wallpaper" +EXTENSIONS="jpg|jpeg|png|gif|webp|bmp|tiff|tga|svg|avif" + +declare -A wall_map +while IFS= read -r path; do + name=$(basename "$path") + wall_map["$name"]="$path" +done < <(find "$WALLPAPER_DIR" -maxdepth 1 -type f \ + -regextype posix-extended -iregex ".*\.($EXTENSIONS)" | sort) + +chosen=$(printf '%s\n' "${!wall_map[@]}" | sort | \ + wofi \ + --dmenu \ + --prompt " Wallpaper" \ + --insensitive \ + --no-actions \ + --width 500 \ + --height 400 \ +) + +[[ -z "$chosen" ]] && exit 0 + +full_path="${wall_map[$chosen]}" +[[ ! -f "$full_path" ]] && { + notify-send "wallpaper-picker" "Not found: $full_path" --urgency=critical + exit 1 +} + +awww img "$full_path" --transition-type grow --transition-step 90 + +persist="$HOME/.config/hypr/wallpaper-restore.sh" +printf '#!/bin/bash\nawww-daemon &\nsleep 0.5\nawww img "%s" --transition-type simple\n' "$full_path" > "$persist" +chmod +x "$persist" + +notify-send "Wallpaper" "$chosen" --urgency=low diff --git a/files/wallpaper-restore.sh b/files/wallpaper-restore.sh index e4816a7..65a344b 100755 --- a/files/wallpaper-restore.sh +++ b/files/wallpaper-restore.sh @@ -1,4 +1,4 @@ #!/bin/bash awww-daemon & sleep 0.5 -awww img "/home/denode/Pictures/wallpaper/mountain02.jpg" --transition-type simple +awww img "/home/denode/Pictures/wallpaper/mountain04.jpg" --transition-type simple