mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 14:59:27 -05:00
fix(wallpaper/konachan): make random konachan respect locale by utilizing xdg user dirs (if any) (#1662)
This commit is contained in:
@@ -1,24 +1,42 @@
|
||||
#!/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/Wallpapers
|
||||
page=$((1 + RANDOM % 1000));
|
||||
mkdir -p "$PICTURES_DIR/Wallpapers"
|
||||
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);
|
||||
link=$(echo "$response" | jq '.[0].file_url' -r);
|
||||
ext=$(echo "$link" | awk -F. '{print $NF}')
|
||||
downloadPath="$HOME/Pictures/Wallpapers/konachan_random_image.$ext"
|
||||
downloadPath="$PICTURES_DIR/Wallpapers/konachan_random_image.$ext"
|
||||
illogicalImpulseConfigPath="$HOME/.config/illogical-impulse/config.json"
|
||||
currentWallpaperPath=$(jq -r '.background.wallpaperPath' $illogicalImpulseConfigPath)
|
||||
if [ "$downloadPath" == "$currentWallpaperPath" ]; then
|
||||
downloadPath="$HOME/Pictures/Wallpapers/konachan_random_image-1.$ext"
|
||||
downloadPath="$PICTURES_DIR/Wallpapers/konachan_random_image-1.$ext"
|
||||
fi
|
||||
curl "$link" -o "$downloadPath"
|
||||
"$SCRIPT_DIR/switchwall.sh" --image "$downloadPath"
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
"Fake screen rounding": "伪造屏幕圆角",
|
||||
"When not fullscreen": "非全屏时",
|
||||
"Choose file": "选择文件",
|
||||
"Random SFW Anime wallpaper from Konachan\nImage is saved to ~/Pictures/Wallpapers": "随机 Konachan SFW 动漫壁纸\n图片保存到 ~/Pictures/Wallpapers",
|
||||
"Random SFW Anime wallpaper from Konachan\nImage is saved to ~/Pictures/Wallpapers": "随机 Konachan SFW 动漫壁纸\n图片保存到 ~/图片/Wallpapers",
|
||||
"Be patient...": "请耐心等待...",
|
||||
"Decorations & Effects": "装饰与特效",
|
||||
"Tonal Spot": "色调点",
|
||||
@@ -311,4 +311,4 @@
|
||||
"Humidity": "湿度",
|
||||
"Wind": "风",
|
||||
"Precipitation": "降水量"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user