From cb78290f31886fb1f9a5e7c2a764dda55a459e50 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Sun, 26 Oct 2025 22:23:31 +0400 Subject: chore: split script installation into CLI and GUI sections --- scripts/gui/swall | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 scripts/gui/swall (limited to 'scripts/gui/swall') diff --git a/scripts/gui/swall b/scripts/gui/swall new file mode 100755 index 0000000..8e5ffb6 --- /dev/null +++ b/scripts/gui/swall @@ -0,0 +1,68 @@ +#!/bin/sh + +. slib + +help() { +cat << EOF +${0}: Wrapper script to set wallpapers +options: + -d [File] Select a wallpaper or a directory + -c Remove the current wallpaper + -h Print this message and exit + +NOTE: default directory is ~/.config/wallpapers +EOF + +exit 0 +} + +check_program "xwallpaper" + +if [ "${#}" = 0 ]; then + #FIXME: use XDG_CONFIG + input="${HOME}/.config/wallpapers" +elif [ "${#}" != 1 ] && [ "${#}" != 2 ]; then + invalid_use +fi + +while getopts "hcd:" option; do + case "${option}" in + c) + #FIXME: use `run` function + killall picom + xwallpaper --clear + picom & + exit 0 + ;; + + d) input="${OPTARG}" ;; + + h) help ;; + + *) invalid_use -h ;; + + esac +done + +shift $((OPTIND - 1)) + +[ "${#}" != 0 ] && invalid_use + +if [ -n "${input}" ]; then + case $(file -L -b --mime-type "${input}") in + image/*) image="${input}" ;; + + inode/directory) waldir="${input}" ;; + + *) err "Couldn't read given file" ;; + esac +fi + +if [ -n "${waldir}" ]; then + image=$(find "${waldir}" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' 2>/dev/null \ + | shuf -n 1 ) +fi + +[ -z "${image}" ] && err "No image file found" + +run "xwallpaper --zoom ${image}" "${image}" -- cgit v1.2.3