summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxyz <gky44px1999@gmail.com>2021-08-11 03:17:57 -0700
committerxyz <gky44px1999@gmail.com>2021-08-11 03:17:57 -0700
commit468442fc7bad4d94650ee806a8faf9039e8b081c (patch)
tree9f353f531238054d7e14a7151f4d61316f63f6f6
parent69eacd70499b97bd0c6699f2839ea9d418ee0d87 (diff)
better wallpaper set
-rwxr-xr-x.config/sxiv/exec/key-handler24
-rwxr-xr-x.local/bin/shufwall5
2 files changed, 22 insertions, 7 deletions
diff --git a/.config/sxiv/exec/key-handler b/.config/sxiv/exec/key-handler
index e9b43afd..00f6fa23 100755
--- a/.config/sxiv/exec/key-handler
+++ b/.config/sxiv/exec/key-handler
@@ -19,7 +19,7 @@
# rawtherapee is owned by rawtherapee
rotate() {
- tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read file; do
+ tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read -r file; do
case "$(file -b -i "$file")" in
image/jpeg*) jpegtran -rotate 90 -copy all -outfile "$file" "$file" ;;
*) mogrify -rotate 90 "$file" ;;
@@ -28,7 +28,7 @@ rotate() {
}
flip() {
- tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read file; do
+ tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read -r file; do
case "$(file -b -i "$file")" in
image/jpeg*) jpegtran -flip vertical -copy all -outfile "$file" "$file" ;;
*) mogrify -flip "$file" ;;
@@ -36,14 +36,28 @@ flip() {
done
}
+linkwall() {
+ tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read -r file; do
+ walldir="${HOME}/pictures/wallpapers/"
+ name=$(basename "$file")
+ if [ ! -e "${walldir}${name}" ]; then
+ convwall "$file" "${walldir}${name}" || ln -s "$file" "${walldir}"
+ else
+ notify-send 'error' "${name} exist"
+ fi
+ done
+}
+
+# I choose not to put case nested in while read file loop
+# because it can pipe multiple files to one command?
case "$1" in
"d") [ "$(promptd "delete?")" = "Yes" ] && tr '\n' '\0' | xargs -0 rm ;;
- "e") while read file; do alacritty -e sh -c "exiv2 pr -q -pa '$file' | less" & done ;;
+ "e") while read -r file; do alacritty -e sh -c "exiv2 pr -q -pa '$file' | less" & done ;;
"f") flip ;;
"g") tr '\n' '\0' | xargs -0 setsid -f gimp ;;
- "l") tr '\n' '\0' | xargs -0 realpath -z | xargs -0 ln -s -t "$HOME/pictures/wallpapers" ;;
+ "l") linkwall ;;
"r") rotate ;;
- "w") tr '\n' '\0' | xargs -0 xwallpaper --maximize ;;
+ "w") tr '\n' '\0' | xargs -0 shufwall ;;
"y") tr '\n' '\0' | xargs -0 realpath | xsel -b ;;
esac
diff --git a/.local/bin/shufwall b/.local/bin/shufwall
index 086dd54d..831e614f 100755
--- a/.local/bin/shufwall
+++ b/.local/bin/shufwall
@@ -1,8 +1,9 @@
#!/bin/sh
if [ -z "$1" ]; then
- xwallpaper --maximize "$(find -L ~/pictures/wallpapers -type f | shuf -n 1)"
+ file=$(find -L ~/pictures/wallpapers -type f | shuf -n 1)
else
- xwallpaper --maximize "$(find -L "$@" -maxdepth 1 -type f | shuf -n 1)"
+ file=$(find -L "$@" -maxdepth 1 -type f | shuf -n 1)
fi
+display -backdrop -window root "$file"