From 151a649d94d65d4f5dd63168f373bfbf8f15f431 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Mon, 20 Apr 2020 10:57:33 -0500 Subject: [PATCH] Fix maybe_source_env_file and implement better screenshotting --- apps/de/x/profile | 4 ++-- bin/clipshot | 13 +++++++------ bin/maybe_source_env_file | 6 +++++- bin/screenshot | 2 +- bin/source_if_exists | 6 +++--- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/apps/de/x/profile b/apps/de/x/profile index 5de6379..766838d 100755 --- a/apps/de/x/profile +++ b/apps/de/x/profile @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash [ -z "$XDG_CONFIG_HOME" ] && export XDG_CONFIG_HOME="$HOME/.config" [ -z "$DOTFILES_PATH" ] && export DOTFILES_PATH="$XDG_CONFIG_HOME/dotfiles" @@ -17,4 +17,4 @@ export SSH_AUTH_SOCK xset r rate 250 80 & # keyrepeat -. maybe_source_env_file x/profile +source maybe_source_env_file x/profile diff --git a/bin/clipshot b/bin/clipshot index abc0ddc..1e663ab 100755 --- a/bin/clipshot +++ b/bin/clipshot @@ -5,11 +5,12 @@ if is_wayland; then else pkill unclutter sleep 0.1 - import ~/.ss.png - chmod 700 ~/.ss.png - < ~/.ss.png xclip -t image/png -i -selection clipboard - < ~/.ss.png xclip -t image/png -i -selection primary - < ~/.ss.png xclip -t image/png -i -selection secondary - < ~/.ss.png xclip -t image/png -i -selection buffer-cut + fn="$SCROTS_PATH/clipshot_$(date +"%Y-%m-%d_%H-%M-%S").png" + import "$fn" + chmod 700 "$fn" + < "$fn" xclip -t image/png -i -selection clipboard + < "$fn" xclip -t image/png -i -selection primary + < "$fn" xclip -t image/png -i -selection secondary + < "$fn" xclip -t image/png -i -selection buffer-cut unclutter & fi diff --git a/bin/maybe_source_env_file b/bin/maybe_source_env_file index 647bbc1..eccd8ff 100755 --- a/bin/maybe_source_env_file +++ b/bin/maybe_source_env_file @@ -1,3 +1,7 @@ #!/usr/bin/env bash -f="$1"; shift; . source_if_exists "$ENV_PATH/$f" "$@" +set -xe + +f="$1"; shift +[ -f "$f" ] && source "$f" "$@" +true diff --git a/bin/screenshot b/bin/screenshot index 54d11d3..2c6c4fa 100755 --- a/bin/screenshot +++ b/bin/screenshot @@ -2,5 +2,5 @@ SCROT_DIR="$NICE_HOME/img/scrots" mkdir -p "$SCROT_DIR/" -FILENAME="$SCROT_DIR/%Y-%m-%d_%H-%M-%S_\$wx\$h.png" +FILENAME="$SCROT_DIR/screenshot_%Y-%m-%d_%H-%M-%S_\$wx\$h.png" scrot "$@" "${FILENAME}" >/dev/null && echo "Saved screenshot to: ${FILENAME}" diff --git a/bin/source_if_exists b/bin/source_if_exists index 8f3fd38..6ef4611 100755 --- a/bin/source_if_exists +++ b/bin/source_if_exists @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash [ "$#" -lt 1 ] && { echo "No arguments provided" >&2 ; exit 1; } -[ "$#" -gt 1 ] && { echo "Too many arguments provided" >&2 ; exit 2; } # shellcheck disable=SC1090 -{ [ -f "$1" ] && . "$1"; } || { echo "$1 does not exist" >&2 ; exit 3; } +f="$1"; shift +{ [ -f "$f" ] && source "$f" "$@"; } || { echo "$f does not exist" >&2 ; exit 3; }