From 83be5822b1e8db8bba1fc76cfd9b93eddde60943 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sun, 28 Sep 2025 20:50:21 +0200 Subject: [PATCH] add random osu seasonal wallpaper button --- .../ii/modules/overview/SearchWidget.qml | 2 +- .../ii/modules/settings/QuickConfig.qml | 51 ++++++++++++------- .../{ => random}/random_konachan_wall.sh | 6 +-- .../scripts/colors/random/random_osu_wall.sh | 44 ++++++++++++++++ .config/quickshell/ii/welcome.qml | 2 +- 5 files changed, 83 insertions(+), 22 deletions(-) rename .config/quickshell/ii/scripts/colors/{ => random}/random_konachan_wall.sh (87%) create mode 100755 .config/quickshell/ii/scripts/colors/random/random_osu_wall.sh diff --git a/.config/quickshell/ii/modules/overview/SearchWidget.qml b/.config/quickshell/ii/modules/overview/SearchWidget.qml index c857c0676..53df4b75b 100644 --- a/.config/quickshell/ii/modules/overview/SearchWidget.qml +++ b/.config/quickshell/ii/modules/overview/SearchWidget.qml @@ -42,7 +42,7 @@ Item { // Wrapper { action: "konachanwallpaper", execute: () => { - Quickshell.execDetached([Quickshell.shellPath("scripts/colors/random_konachan_wall.sh")]); + Quickshell.execDetached([Quickshell.shellPath("scripts/colors/random/random_konachan_wall.sh")]); } }, { diff --git a/.config/quickshell/ii/modules/settings/QuickConfig.qml b/.config/quickshell/ii/modules/settings/QuickConfig.qml index ca8a0f73d..b14cb085a 100644 --- a/.config/quickshell/ii/modules/settings/QuickConfig.qml +++ b/.config/quickshell/ii/modules/settings/QuickConfig.qml @@ -14,12 +14,13 @@ ContentPage { forceWidth: true Process { - id: konachanWallProc + id: randomWallProc property string status: "" - command: ["bash", "-c", FileUtils.trimFileProtocol(`${Directories.scriptPath}/colors/random_konachan_wall.sh`)] + property string scriptPath: `${Directories.scriptPath}/colors/random/random_konachan_wall.sh` + command: ["bash", "-c", FileUtils.trimFileProtocol(randomWallProc.scriptPath)] stdout: SplitParser { onRead: data => { - konachanWallProc.status = data.trim(); + randomWallProc.status = data.trim(); } } } @@ -90,19 +91,35 @@ ContentPage { ColumnLayout { RippleButtonWithIcon { - id: rndWallBtn + enabled: !randomWallProc.running visible: Config.options.policies.weeb === 1 Layout.fillWidth: true buttonRadius: Appearance.rounding.small materialIcon: "ifl" - mainText: konachanWallProc.running ? Translation.tr("Be patient...") : Translation.tr("Random: Konachan") + mainText: randomWallProc.running ? Translation.tr("Be patient...") : Translation.tr("Random: Konachan") onClicked: { - konachanWallProc.running = true; + randomWallProc.scriptPath = `${Directories.scriptPath}/colors/random/random_konachan_wall.sh`; + randomWallProc.running = true; } StyledToolTip { text: Translation.tr("Random SFW Anime wallpaper from Konachan\nImage is saved to ~/Pictures/Wallpapers") } } + RippleButtonWithIcon { + enabled: !randomWallProc.running + visible: Config.options.policies.weeb === 1 + Layout.fillWidth: true + buttonRadius: Appearance.rounding.small + materialIcon: "ifl" + mainText: randomWallProc.running ? Translation.tr("Be patient...") : Translation.tr("Random: osu! seasonal") + onClicked: { + randomWallProc.scriptPath = `${Directories.scriptPath}/colors/random/random_osu_wall.sh`; + randomWallProc.running = true; + } + StyledToolTip { + text: Translation.tr("Random osu! seasonal background\nImage is saved to ~/Pictures/Wallpapers") + } + } RippleButtonWithIcon { Layout.fillWidth: true materialIcon: "wallpaper" @@ -154,17 +171,6 @@ ContentPage { dark: true } } - - ConfigSwitch { - text: Translation.tr("Transparency") - checked: Config.options.appearance.transparency.enable - onCheckedChanged: { - Config.options.appearance.transparency.enable = checked; - } - StyledToolTip { - text: Translation.tr("Might look ass. Unsupported.") - } - } } } @@ -213,6 +219,17 @@ ContentPage { } ] } + + ConfigSwitch { + text: Translation.tr("Transparency") + checked: Config.options.appearance.transparency.enable + onCheckedChanged: { + Config.options.appearance.transparency.enable = checked; + } + StyledToolTip { + text: Translation.tr("Might look ass. Unsupported.") + } + } } ContentSection { diff --git a/.config/quickshell/ii/scripts/colors/random_konachan_wall.sh b/.config/quickshell/ii/scripts/colors/random/random_konachan_wall.sh similarity index 87% rename from .config/quickshell/ii/scripts/colors/random_konachan_wall.sh rename to .config/quickshell/ii/scripts/colors/random/random_konachan_wall.sh index a4685da95..a1f922121 100755 --- a/.config/quickshell/ii/scripts/colors/random_konachan_wall.sh +++ b/.config/quickshell/ii/scripts/colors/random/random_konachan_wall.sh @@ -32,11 +32,11 @@ page=$((1 + RANDOM % 1000)); response=$(curl "https://konachan.net/post.json?tags=rating%3Asafe&limit=1&page=$page") link=$(echo "$response" | jq '.[0].file_url' -r); ext=$(echo "$link" | awk -F. '{print $NF}') -downloadPath="$PICTURES_DIR/Wallpapers/konachan_random_image.$ext" +downloadPath="$PICTURES_DIR/Wallpapers/random_wallpaper.$ext" illogicalImpulseConfigPath="$HOME/.config/illogical-impulse/config.json" currentWallpaperPath=$(jq -r '.background.wallpaperPath' $illogicalImpulseConfigPath) if [ "$downloadPath" == "$currentWallpaperPath" ]; then - downloadPath="$PICTURES_DIR/Wallpapers/konachan_random_image-1.$ext" + downloadPath="$PICTURES_DIR/Wallpapers/random_wallpaper-1.$ext" fi curl "$link" -o "$downloadPath" -"$SCRIPT_DIR/switchwall.sh" --image "$downloadPath" +"$SCRIPT_DIR/../switchwall.sh" --image "$downloadPath" diff --git a/.config/quickshell/ii/scripts/colors/random/random_osu_wall.sh b/.config/quickshell/ii/scripts/colors/random/random_osu_wall.sh new file mode 100755 index 000000000..54b3af6a0 --- /dev/null +++ b/.config/quickshell/ii/scripts/colors/random/random_osu_wall.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +get_pictures_dir() { + if command -v xdg-user-dir &> /dev/null; then + xdg-user-dir PICTURES + return + fi + + local config_file="${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs" + if [ -f "$config_file" ]; then + local pictures_path + pictures_path=$(source "$config_file" >/dev/null 2>&1; echo "$XDG_PICTURES_DIR") + echo "${pictures_path/#\$HOME/$HOME}" + return + fi + + echo "$HOME/Pictures" +} + +QUICKSHELL_CONFIG_NAME="ii" +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" +XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" +PICTURES_DIR=$(get_pictures_dir) +CONFIG_DIR="$XDG_CONFIG_HOME/quickshell/$QUICKSHELL_CONFIG_NAME" +CACHE_DIR="$XDG_CACHE_HOME/quickshell" +STATE_DIR="$XDG_STATE_HOME/quickshell" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +mkdir -p "$PICTURES_DIR/Wallpapers" + +response=$(curl "https://osu.ppy.sh/api/v2/seasonal-backgrounds") +images=$(echo "$response" | jq '.backgrounds | length' -r); +randomIndex=$((RANDOM % images)); +link=$(echo "$response" | jq ".backgrounds[$randomIndex].url" -r) +ext=$(echo "$link" | awk -F. '{print $NF}') +downloadPath="$PICTURES_DIR/Wallpapers/random_wallpaper.$ext" +illogicalImpulseConfigPath="$HOME/.config/illogical-impulse/config.json" +currentWallpaperPath=$(jq -r '.background.wallpaperPath' $illogicalImpulseConfigPath) +if [ "$downloadPath" == "$currentWallpaperPath" ]; then + downloadPath="$PICTURES_DIR/Wallpapers/random_wallpaper-1.$ext" +fi +curl "$link" -o "$downloadPath" +"$SCRIPT_DIR/../switchwall.sh" --image "$downloadPath" diff --git a/.config/quickshell/ii/welcome.qml b/.config/quickshell/ii/welcome.qml index 1f7e0dc22..4acd2c80b 100644 --- a/.config/quickshell/ii/welcome.qml +++ b/.config/quickshell/ii/welcome.qml @@ -44,7 +44,7 @@ ApplicationWindow { Process { id: konachanWallProc property string status: "" - command: ["bash", "-c", Quickshell.shellPath("scripts/colors/random_konachan_wall.sh")] + command: ["bash", "-c", Quickshell.shellPath("scripts/colors/random/random_konachan_wall.sh")] stdout: SplitParser { onRead: data => { console.log(`Konachan wall proc output: ${data}`);