From 389cbc1b86743ae983f7914e1f3751c0ea0be01c Mon Sep 17 00:00:00 2001 From: appeasementPolitik <108810900+appeasementPolitik@users.noreply.github.com> Date: Mon, 15 Jul 2024 17:28:50 +0000 Subject: [PATCH 1/4] weath: Add option to get forecast from a different location (#1327) * weath: Add option to get forecast from a different location * Remove retry and make max time lower because it is interactive * Give weath 'cp' option to copy forecast as plain text for sharing * Make weath a separate script --- .config/shell/aliasrc | 3 +-- .local/bin/weath | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 .local/bin/weath diff --git a/.config/shell/aliasrc b/.config/shell/aliasrc index 09f9a327..07683372 100644 --- a/.config/shell/aliasrc +++ b/.config/shell/aliasrc @@ -16,7 +16,7 @@ done; unset command se() { choice="$(find ~/.local/bin -mindepth 1 -printf '%P\n' | fzf)" [ -f "$HOME/.local/bin/$choice" ] && $EDITOR "$HOME/.local/bin/$choice" - ;} + } # Verbosity and settings that you pretty much just always are going to want. alias \ @@ -58,4 +58,3 @@ alias \ lf="lfub" \ magit="nvim -c MagitOnly" \ ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" \ - weath="less -S ${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" \ diff --git a/.local/bin/weath b/.local/bin/weath new file mode 100644 index 00000000..a5264110 --- /dev/null +++ b/.local/bin/weath @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Get the weather on the terminal. You can pass an alternative location as a parameter, +# and/or use the 'cp' option to copy the forecast as plaintext to the clipboard. + +report="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" + +if [ "$1" = 'cp' ]; then + # shellcheck disable=SC2015 + [ -z "$2" ] && sed 's/\x1b\[[^m]*m//g' "$report" | xclip -selection clipboard && + notify-send "Weather forecast for '${LOCATION:-$(head -n 1 "$report" | cut -d' ' -f3-)}' copied to clipboard." || + { data="$(curl -sfm 5 "${WTTRURL:-wttr.in}/$2?T")" && + notify-send "Weather forecast for '$2' copied to clipboard." && + echo "$data" | xclip -selection clipboard || + notify-send 'Failed to get weather forecast!' 'Check your internet connection and the supplied location.'; } +else + [ -n "$2" ] && + notify-send "Invalid option '$1'! The only valid option is 'cp'." && + exit 1 + + # shellcheck disable=SC2015 + [ -z "$1" ] && less -S "$report" || + data="$(curl -sfm 5 "${WTTRURL:-wttr.in}/$1")" && echo "$data" | less -S || + notify-send 'Failed to get weather forecast!' 'Check your internet connection and the supplied location.' +fi From e6ea8e06e6f63c59f885fe3eaf0107d503a63fc6 Mon Sep 17 00:00:00 2001 From: Kipras Melnikovas Date: Mon, 15 Jul 2024 20:37:04 +0300 Subject: [PATCH 2/4] shortcuts: export env vars for each shortcut (#1395) useful if want to use shortcuts w/ different progs instead of their default behavior (cd / $EDITOR), e.g.: ```sh cd ~/Downloads mv foo.mp3 $music ``` Co-authored-by: Luke Smith --- .config/shell/aliasrc | 2 +- .config/zsh/.zshrc | 1 + .local/bin/shortcuts | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.config/shell/aliasrc b/.config/shell/aliasrc index 07683372..75327bf7 100644 --- a/.config/shell/aliasrc +++ b/.config/shell/aliasrc @@ -57,4 +57,4 @@ alias \ alias \ lf="lfub" \ magit="nvim -c MagitOnly" \ - ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" \ + ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 8af5d134..ff7d4ae5 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -15,6 +15,7 @@ setopt inc_append_history # Load aliases and shortcuts if existent. [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" +[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" diff --git a/.local/bin/shortcuts b/.local/bin/shortcuts index 0c7cf75d..08a2f57d 100755 --- a/.local/bin/shortcuts +++ b/.local/bin/shortcuts @@ -5,6 +5,7 @@ bmfiles="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-files" # Output locations. Unactivated progs should go to /dev/null. shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" +shell_env_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" lf_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc" vim_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/nvim/shortcuts.vim" @@ -16,12 +17,14 @@ vifm_shortcuts="/dev/null" rm -f "$lf_shortcuts" "$qute_shortcuts" "$zsh_named_dirs" "$vim_shortcuts" 2>/dev/null printf "# vim: filetype=sh\\n" > "$fish_shortcuts" printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts" +printf "# vim: filetype=sh\\n" > "$shell_env_shortcuts" printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" # Format the `directories` file in the correct syntax and sent it to all three configs. eval "echo \"$(cat "$bmdirs")\"" | \ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"%s=\42cd %s && ls -A\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ; + printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" ; printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; printf(\"abbr %s \42cd %s; and ls -A\42\n\",\$1,\$2) >> \"$fish_shortcuts\" ; printf(\"map g%s :cd %s\nmap t%s :cd %s\nmap M%s :cd %s:mo\nmap Y%s :cd %s:co \n\",\$1,\$2, \$1, \$2, \$1, \$2, \$1, \$2) >> \"$vifm_shortcuts\" ; @@ -33,6 +36,7 @@ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); eval "echo \"$(cat "$bmfiles")\"" | \ awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\"); printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ; + printf(\"[ -n \42%s\42 ] && export %s=\42%s\42 \n\",\$1,\$1,\$2) >> \"$shell_env_shortcuts\" ; printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ; printf(\"abbr %s \42\$EDITOR %s\42 \n\",\$1,\$2) >> \"$fish_shortcuts\" ; printf(\"map %s :e %s \n\",\$1,\$2) >> \"$vifm_shortcuts\" ; From d5601ec52329190776c71a7abcfd411f4bc9e788 Mon Sep 17 00:00:00 2001 From: fennomaani <160141733+fennomaani@users.noreply.github.com> Date: Mon, 15 Jul 2024 20:37:38 +0300 Subject: [PATCH 3/4] Update mpd to use PipeWire (#1412) per https://wiki.archlinux.org/title/Music_Player_Daemon#Audio_configuration --- .config/mpd/mpd.conf | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.config/mpd/mpd.conf b/.config/mpd/mpd.conf index bf329d61..1cc2cc81 100644 --- a/.config/mpd/mpd.conf +++ b/.config/mpd/mpd.conf @@ -7,10 +7,8 @@ restore_paused "yes" max_output_buffer_size "16384" audio_output { - type "pulse" - name "pulse" - #type "alsa" - #name "ALSA" + type "pipewire" + name "PipeWire Sound Server" } audio_output { From 0aeaa081f69c0f48224b085a0b5cbb4c5169ce10 Mon Sep 17 00:00:00 2001 From: ngorden Date: Sat, 19 Oct 2024 10:46:35 -0700 Subject: [PATCH 4/4] New: create sb-ticker --- .local/bin/statusbar/sb-ticker | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 .local/bin/statusbar/sb-ticker diff --git a/.local/bin/statusbar/sb-ticker b/.local/bin/statusbar/sb-ticker new file mode 100755 index 00000000..4042a3d6 --- /dev/null +++ b/.local/bin/statusbar/sb-ticker @@ -0,0 +1,50 @@ +#!/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$(getchange) + +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