summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-03-26 00:36:52 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-03-26 00:36:52 +0900
commit1d2a657c300fdddfe47dda9eea4b896cbf44872b (patch)
tree28b9cf509cba8f9dd35f0a6d226111811efc196f
parentd9151467e4a85271333bf3e688797fba79ed2d93 (diff)
modified zsh/scripts.zsh, modified bin/ecrypt, modified statusbar/sb-ecrypt, created statusbar/sb-ticker
-rw-r--r--ar/.config/zsh/scripts.zsh5
-rwxr-xr-xar/.local/bin/ecrypt6
-rwxr-xr-xar/.local/bin/statusbar/sb-ecrypt4
-rwxr-xr-xar/.local/bin/statusbar/sb-ticker53
4 files changed, 61 insertions, 7 deletions
diff --git a/ar/.config/zsh/scripts.zsh b/ar/.config/zsh/scripts.zsh
index 05561d7..8c46c38 100644
--- a/ar/.config/zsh/scripts.zsh
+++ b/ar/.config/zsh/scripts.zsh
@@ -293,9 +293,8 @@ function fzf_directory() {
# search scripts in ~/.local/bin
alias sscs=search_scripts
function search_scripts() {
- scripts=("${HOME}/.local/bin/"**/*(.))
- choice="$(print -lnr ${scripts:t:r} | fzf)"
- [[ "${choice}" ]] && "${EDITOR}" ${${(M)scripts:#*/${choice}*}[1]}
+ choice="$(find ${HOME}/.local/bin -mindepth 1 -not -path "${HOME}/.local/bin/zsh" -not -path "${HOME}/.local/bin/zsh/*" -printf '%P\n' | fzf)"
+ [ -f "$HOME/.local/bin/$choice" ] && $EDITOR "$HOME/.local/bin/$choice"
}
# check git status by directories in specific path
diff --git a/ar/.local/bin/ecrypt b/ar/.local/bin/ecrypt
index ace0eb7..67b705d 100755
--- a/ar/.local/bin/ecrypt
+++ b/ar/.local/bin/ecrypt
@@ -7,7 +7,11 @@ mount_encrypted() {
attempt_mount() {
if mount | grep -q " $2 "; then
- sudo umount "$2" && notify-send "🔒 Locked: $3" || notify-send "❗ Unable to lock" "Mounted: $3"
+ if sudo umount "$2"; then
+ notify-send "🔒 Locked: $3"
+ else
+ notify-send "❗ Unable to lock" "Mounted: $3"
+ fi
else
ECRYPTFS_SIG=$(pass show encryption/ecryptfs-sig-"$4")
FNEK_SIG=$ECRYPTFS_SIG
diff --git a/ar/.local/bin/statusbar/sb-ecrypt b/ar/.local/bin/statusbar/sb-ecrypt
index 24c4cb3..f07b994 100755
--- a/ar/.local/bin/statusbar/sb-ecrypt
+++ b/ar/.local/bin/statusbar/sb-ecrypt
@@ -1,7 +1,5 @@
#!/bin/sh
-is_mounted() { mount | grep -q "$HOME/Private"; }
-
case $BLOCK_BUTTON in
1) "${XDG_SCRIPTS_HOME:-${HOME}/.local/bin}/ecrypt" ;;
3) notify-send "🔒 Encrypted Media Folder " "\- Shows mount status of Media
@@ -9,4 +7,4 @@ case $BLOCK_BUTTON in
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
-is_mounted "$MOUNT_POINT" && echo "🔑" || echo "🔒"
+mount | grep -q "$HOME/Private" && echo "🔑" || echo "🔒"
diff --git a/ar/.local/bin/statusbar/sb-ticker b/ar/.local/bin/statusbar/sb-ticker
new file mode 100755
index 0000000..f68b6bd
--- /dev/null
+++ b/ar/.local/bin/statusbar/sb-ticker
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# Usage
+# sb-ticker
+# Sample output
+# ^DJI: 0.09%
+# CL=F: -1.88%
+# Description
+# displays/retrieves the latest percent-change in stock market quotes listed in $XDG_CONFIG_HOME/tickers.
+# defaults to S&P 500, Dow Jones Industrial, and the Nasdaq
+#
+# intended to be used in the statusbar, which will display the first quote price in the output
+
+url="terminal-stocks.dev"
+pricefile="${XDG_CACHE_HOME:-$HOME/.cache}/stock-prices"
+tickerfile="${XDG_CONFIG_HOME:-$HOME/.config}/tickers"
+
+[ -f "$tickerfile" ] && tickers="$(cat "$tickerfile")" || tickers="^GSPC,^DJI,^IXIC"
+
+checkprice() {
+ [ -s "$pricefile" ] && [ "$(stat -c %y "$pricefile" 2>/dev/null |
+ cut -d':' -f1)" != "$(date '+%Y-%m-%d %H')" ]
+}
+
+getchange() {
+ mapfile -t changes < <(sed -e 's/ / /g' "$pricefile" | grep -oe '[m-]\+[0-9]\+\.[0-9]\+' | sed 's/[m ]/;/g')
+ IFS=',' read -ra TICKER <<<"$tickers"
+ for idx in "${!TICKER[@]}"; do
+ printf "%s: %s%%\n" "${TICKER[$idx]}" "${changes[$idx]//;/}"
+ done
+}
+
+updateprice() { curl -sfm 10 "$url/$tickers" --output "$pricefile" || rm -f "$pricefile"; }
+
+case $BLOCK_BUTTON in
+1) setsid "$TERMINAL" -e less -Srf "$pricefile" ;;
+2)
+ notify-send -u low "Updating..." "Updating prices"
+ updateme="1"
+ ;;
+3) notify-send "Current prices:" "Current stock prices:\n<b>$(getchange)</b>
+
+LEFT MOUSE BUTTON: show price file
+MIDDLE MOUSE BUTTON: update stock prices
+RIGHT MOUSE BUTTON: Get stock overview" ;;
+6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+[ -n "$updateme" ] && updateprice
+
+[ -f "$pricefile" ] && getchange
+
+checkprice && updateprice