summaryrefslogtreecommitdiff
path: root/scripts/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gui')
-rwxr-xr-xscripts/gui/nsend28
-rwxr-xr-xscripts/gui/sclip21
-rwxr-xr-xscripts/gui/sslock49
-rwxr-xr-xscripts/gui/swall3
4 files changed, 79 insertions, 22 deletions
diff --git a/scripts/gui/nsend b/scripts/gui/nsend
index 80e1764..1bfc1f4 100755
--- a/scripts/gui/nsend
+++ b/scripts/gui/nsend
@@ -14,19 +14,21 @@ EOF
exit 0
}
-check_program "notify-send" "libnotify must be installed"
-
-case "${1}" in
-"-s")
- [ "${#}" -gt 3 ] && invalid_use
-
- shift
- eval $(printf 'notify-send "%s" "%s"' "${1}" "${2}")
-
- exit 0
+case "${#}" in
+1)
+ [ "${1}" = "-h" ] && help
+ invalid_use
+;;
+2)
+ [ "${1}" = "-s" ] || invalid_use
+ notification_string="${2}"
+;;
+3)
+ [ "${1}" = "-s" ] || invalid_use
+ notification_string="${2}: ${3}"
;;
-"-h") help ;;
-
*) invalid_use ;;
-
esac
+
+
+send_notification "${notification_string}"
diff --git a/scripts/gui/sclip b/scripts/gui/sclip
index 3666448..3d2caa5 100755
--- a/scripts/gui/sclip
+++ b/scripts/gui/sclip
@@ -18,12 +18,15 @@ exit 0
check_program "xclip"
i_flg=0
-while getopts "f:c:ih" option; do
+silent=0
+while getopts "f:c:sih" option; do
case "${option}" in
f) filepath="${OPTARG}" ;;
c) input="${OPTARG}" ;;
+ s) silent=1 ;;
+
i) i_flg=1 ;;
h) help ;;
@@ -38,6 +41,11 @@ shift $((OPTIND - 1))
if [ -n "${filepath}" ]; then
mime_type=$(file --mime-type -b "${filepath}")
+
+ if [ "${silent}" -eq 1 ]; then
+ run "xclip -selection clipboard -t ${mime_type} -i ${filepath}"
+ fi
+
run --success-notify "${filepath} copied" \
--failure-notify "${filepath} failed to copy" \
"xclip -selection clipboard -t ${mime_type} -i ${filepath}"
@@ -46,8 +54,17 @@ fi
[ "${i_flg}" -eq 1 ] && input=$(cat)
if [ -n "${input}" ]; then
+ # Don't use `run` since pipes are used
printf '%s' "${input}" | xclip -selection clipboard
- exit 0
+
+ if [ $? -eq 0 ]; then
+ [ "${silent}" -eq 0 ] && send_notification "${argv0}:" "'${input}' copied"
+ exit 0
+ fi
+
+ [ "${silent}" -eq 0 ] && send_notification "${argv0}:" "'${input}' failed to copy"
+
+ exit 1
fi
run "xclip -o -selection clipboard"
diff --git a/scripts/gui/sslock b/scripts/gui/sslock
index 0751de7..26ba2cf 100755
--- a/scripts/gui/sslock
+++ b/scripts/gui/sslock
@@ -4,7 +4,12 @@
help() {
cat << EOF
-${0}: Wrapper script to set lock the screen
+${0}: Wrapper script to take screenshots
+options:
+ -n Black screen
+ -b Blur
+ -c Take the current state of the desktop
+ -h Print this message and exit
EOF
exit 0
@@ -12,9 +17,43 @@ exit 0
check_program "slock"
-[ "${#}" -eq 1 ] && [ "${1}" = "-h" ] && help
+blur=0
+set_current_state=0
+current_wallpaper="${XDG_CACHE_HOME:-$HOME/.cache}/wallpaper/current"
+while getopts "bcnh" option; do
+ case "${option}" in
+ b)
+ check_program "mogrify" "imagemagick must be installed"
+ blur=1 ;;
-[ "${#}" != 0 ] && invalid_use
+ c)
+ check_program "scrot"
+ set_current_state=1
+ ;;
+ n)
+ slock
+ exit 0;;
-BACKGROUND="${XDG_CACHE_HOME:-$HOME/.cache}/wallpaper/current"
-slock -f "${BACKGROUND}"
+ h) help ;;
+
+ *) invalid_use -h ;;
+
+ esac
+done
+
+shift $((OPTIND - 1))
+
+[ "${#}" -eq 0 ] || invalid_use
+
+background="/tmp/$(date '+%b%d::%H%M%S').png"
+
+if [ "$set_current_state" -eq 0 ]; then
+ # Avoid distorting the wallpaper when calling `mogrify`
+ cp "${current_wallpaper}" "${background}"
+else
+ scrot -z "${background}"
+fi
+
+[ "${blur}" -eq 1 ] && mogrify -blur 0x8 "${background}"
+
+slock -f "${background}"
diff --git a/scripts/gui/swall b/scripts/gui/swall
index 9cb9e39..a225481 100755
--- a/scripts/gui/swall
+++ b/scripts/gui/swall
@@ -18,7 +18,6 @@ EOF
exit 0
}
-
check_program "xwallpaper"
SYMLINK="${XDG_CACHE_HOME:-$HOME/.cache}/wallpaper/current"
@@ -59,7 +58,7 @@ if [ -n "${input}" ]; then
fi
if [ -n "${waldir}" ]; then
- image=$(find "${waldir}" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' 2>/dev/null \
+ image=$(find "${waldir}" -iregex '.*.\(jpg\|jpeg\|png\)' 2>/dev/null \
| shuf -n 1 )
fi