commit 4a4af4f70cf90a84c590806e8528dc69537b03e8
parent 465b1fcfb09040680e1e13ad7ea961036b3f9cce
Author: Matthew Carlson <matt@mcarlson.xyz>
Date: Thu, 22 Jul 2021 22:09:51 -0400
mime stuff and wallpaper script
Diffstat:
4 files changed, 97 insertions(+), 3 deletions(-)
diff --git a/.config/mimeapps.list b/.config/mimeapps.list
@@ -17,13 +17,28 @@ audio/x-m4a=audio.desktop
audio/x-wav=audio.desktop
# image
+image/bmp=img.desktop
image/gif=gif.desktop
image/jpeg=img.desktop
+image/pjpeg=img.desktop
image/png=img.desktop
+image/tiff-fx=img.desktop
+image/tiff=img.desktop
image/vnd.djvu=doc.desktop
+image/vnd.microsoft.icon=img.desktop
image/webp=img.desktop
+image/x-icon=img.desktop
+image/x-portable-anymap=img.desktop
+image/x-portable-bitmap=img.desktop
+image/x-portable-graymap=img.desktop
+image/x-portable-pixmap=img.desktop
image/x-targa=img.desktop
image/x-tga=img.desktop
+image/x-tiff=img.desktop
+image/x-windows-bmp=img.desktop
+image/x-xpixmap=img.desktop
+image/x-xpmi=img.desktop
+image/xpm=img.desktop
# text
text/css=txt.desktop
diff --git a/.config/sh/aliasrc b/.config/sh/aliasrc
@@ -22,7 +22,8 @@ alias \
# gnu/linux
alias \
- free='free -m'
+ free='free -m' \
+ o='xdg-open'
# startx
[ -f "${XINITRC}" ] && alias startx='startx ${XINITRC}'
diff --git a/.local/bin/open.sh b/.local/bin/open.sh
@@ -26,11 +26,26 @@ case "${1}" in
;;
# image
- *.jpeg \
+ *.bmp \
+ | *.dib \
+ | *.ff \
+ | *.gif \
+ | *.ico \
+ | *.iff \
+ | *.jfi \
+ | *.jfif \
+ | *.jif \
+ | *.jpe \
+ | *.jpeg \
| *.jpg \
+ | *.lbm \
| *.png \
+ | *.pnm \
| *.tga \
- | *.webp)
+ | *.tif \
+ | *.tiff \
+ | *.webp \
+ | *.xpm)
"${IMG_VIEWER}" "${1}"
;;
diff --git a/.local/bin/wp.sh b/.local/bin/wp.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+#
+# wp
+
+WP_DIR="${XDG_DATA_HOME:-${HOME}/.local/share}/wp"
+
+get_rand_file() {
+ flag=1
+
+ files="$(for file in "${1}"/*; do
+ [ -d "${file}" ] && continue
+ printf '%s\n' "${file}"
+ done)"
+
+ file=''
+ while ! check_file "${file}"; do
+ file="$(printf '%s' "${files}" | shuf -n 1)"
+ files="$(printf '%s' "${files}" | grep -vw "${file}")"
+ [ -z "${files}" ] && break
+ done
+
+ if ! check_file "${file}"; then file=''; fi
+ [ -z "${file}" ] && flag=1 || flag=0
+
+ return ${flag}
+}
+
+check_file () {
+ file="${1}"
+ ext="${file##*.}"
+ case "${ext}" in
+ # formats supported by imlib2 used by feh, sxiv, etc.
+ bmp \
+ | dib \
+ | ff \
+ | gif \
+ | ico \
+ | iff \
+ | jfi \
+ | jfif \
+ | jif \
+ | jpe \
+ | jpeg \
+ | jpg \
+ | lbm \
+ | png \
+ | pnm \
+ | tga \
+ | tif \
+ | tiff \
+ | webp \
+ | xpm) return 0 ;;
+ *) return 1 ;;
+ esac
+}
+
+wp () {
+ feh --no-fehbg --bg-scale "${1}"
+}
+
+{ [ -d "${1}" ] && get_rand_file "${1}" && flag=${?} ; } || { [ -f "${1}" ] && check_file "${1}" && flag=${?} ; }
+
+[ ${flag} = "0" ] && [ -n "${file}" ] && wp "${file}"