From 47ea7f888cb0117635d69ba6d36464714801c9af Mon Sep 17 00:00:00 2001 From: Warrick Lo Date: Fri, 3 Dec 2021 05:50:44 -0800 Subject: Add shell scripts --- bin/setbg | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 bin/setbg (limited to 'bin/setbg') diff --git a/bin/setbg b/bin/setbg new file mode 100755 index 0000000..e01627f --- /dev/null +++ b/bin/setbg @@ -0,0 +1,26 @@ +#!/bin/sh + +# Set images as background with feh. + +# Get absolute path of file. +if ! file="$(realpath "$1" 2> /dev/null)"; then + echo "Usage: setbg " + exit 0 +fi + +# Check if file is an image. +case "$(file -bi "$file")" in + image/*) + ;; + *) + echo "setbg: invalid file operand" 1>&2 + exit 1 + ;; +esac + +printf -- "#!/bin/sh\n\n" > "$HOME/bin/bg" +printf -- "feh --no-fehbg --bg-scale %s\n" "$file" >> "$HOME/bin/bg" +chmod 755 "$HOME/bin/bg" + +sh "$HOME/bin/bg" +exit 0 -- cgit v1.2.3