summaryrefslogtreecommitdiff
path: root/home/xyz/.local/bin
diff options
context:
space:
mode:
authorXiao Pan <gky44px1999@gmail.com>2023-05-31 18:09:04 -0700
committerXiao Pan <gky44px1999@gmail.com>2023-05-31 18:09:04 -0700
commitff6261c2772612a7a5949737660614ee24b61587 (patch)
tree4fb5b3d5cfa1af5dd815254199e49c2d4b9f841c /home/xyz/.local/bin
parent64d9b8ceca239d89c444e114651cf6eab62df1b4 (diff)
init
Diffstat (limited to 'home/xyz/.local/bin')
-rwxr-xr-xhome/xyz/.local/bin/alacritty6
-rwxr-xr-xhome/xyz/.local/bin/alarm11
-rwxr-xr-xhome/xyz/.local/bin/backlight23
-rwxr-xr-xhome/xyz/.local/bin/bell7
-rwxr-xr-xhome/xyz/.local/bin/ccgsl7
-rwxr-xr-xhome/xyz/.local/bin/chatgpt3
-rwxr-xr-xhome/xyz/.local/bin/curlqb23
-rwxr-xr-xhome/xyz/.local/bin/dateft29
-rwxr-xr-xhome/xyz/.local/bin/grrc4
-rwxr-xr-xhome/xyz/.local/bin/il6
-rwxr-xr-xhome/xyz/.local/bin/mpva17
-rwxr-xr-xhome/xyz/.local/bin/mpvy44
-rwxr-xr-xhome/xyz/.local/bin/mrt51
-rwxr-xr-xhome/xyz/.local/bin/news29
-rwxr-xr-xhome/xyz/.local/bin/rate11
-rwxr-xr-xhome/xyz/.local/bin/reco28
-rwxr-xr-xhome/xyz/.local/bin/sbar68
-rwxr-xr-xhome/xyz/.local/bin/ta5
-rwxr-xr-xhome/xyz/.local/bin/topa8
l---------home/xyz/.local/bin/zoom1
20 files changed, 0 insertions, 381 deletions
diff --git a/home/xyz/.local/bin/alacritty b/home/xyz/.local/bin/alacritty
deleted file mode 100755
index 8ccc3a4b..00000000
--- a/home/xyz/.local/bin/alacritty
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-# https://github.com/MithicSpirit/dotfiles/blob/bb5cce2268f473e5b17759448ee7715b4163fe66/.local/bin/alacritty
-# use `--working-directory "$PWD"` so when do `o .` will launch alacritty in current dir
-# without `msg create-window` no need --working-directory for `o .` to work
-/usr/bin/alacritty msg create-window --working-directory "$PWD" "$@" || exec /usr/bin/alacritty "$@"
diff --git a/home/xyz/.local/bin/alarm b/home/xyz/.local/bin/alarm
deleted file mode 100755
index 5342e7db..00000000
--- a/home/xyz/.local/bin/alarm
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-min="$1"
-[ "$1" ] && shift
-printf "notify-send -u critical %s; bell" "$(/usr/bin/printf '%q ' "${@:-alarm}")" | at now + "${min:-0}" minutes && [ "$min" ] && [ "$min" -ne 0 ] && notify-send "Successfully Scheduled"
-
-# at used to not like string like 'Boiling Water!', don't know why now it works, if see similar issue, use folllowing codes
-#at now + "$1" minutes << EOF && notify-send 'Successfully Scheduled'
-#notify-send -u critical "${2:-alarm}"
-#bell
-#EOF
diff --git a/home/xyz/.local/bin/backlight b/home/xyz/.local/bin/backlight
deleted file mode 100755
index 3de87f56..00000000
--- a/home/xyz/.local/bin/backlight
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-brightness=$(cat /sys/class/backlight/intel_backlight/brightness)
-max_brightness=$(cat /sys/class/backlight/intel_backlight/max_brightness)
-step=$((max_brightness/20))
-
-case "$1" in
- '-u')
- case "$brightness" in
- 0) echo 1;;
- 1) echo "$step";;
- *) echo "$((brightness+step))";;
- esac
- ;;
- '-d')
- case "$brightness" in
- 1) echo 0;;
- "$step") echo 1;;
- *) echo "$((brightness-step))";;
- esac
- ;;
- *) exit 1;;
-esac > /sys/class/backlight/intel_backlight/brightness
diff --git a/home/xyz/.local/bin/bell b/home/xyz/.local/bin/bell
deleted file mode 100755
index a0395aca..00000000
--- a/home/xyz/.local/bin/bell
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-bef="$(amixer get Master | awk -F '[][]' 'END{print $2}')"
-amixer set Master 10%
-# code steal from https://unix.stackexchange.com/a/163716/459013
-speaker-test -t sine -f 1000 -l 1
-amixer set Master "$bef"
diff --git a/home/xyz/.local/bin/ccgsl b/home/xyz/.local/bin/ccgsl
deleted file mode 100755
index 31bd3256..00000000
--- a/home/xyz/.local/bin/ccgsl
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-# steal codes from https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/compiler
-
-base="${1%.*}"
-# -lm link math library? needed for sqrt(). not sure
-# https://stackoverflow.com/questions/44175151/what-is-the-meaning-of-lm-in-gcc
-cc -Wall -lgsl -lgslcblas -lm -o "$base" "$1" && ./"$base"
diff --git a/home/xyz/.local/bin/chatgpt b/home/xyz/.local/bin/chatgpt
deleted file mode 100755
index 2c3836de..00000000
--- a/home/xyz/.local/bin/chatgpt
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-OPENAI_KEY="$(pass openai_key)" /usr/bin/chatgpt
diff --git a/home/xyz/.local/bin/curlqb b/home/xyz/.local/bin/curlqb
deleted file mode 100755
index d40ff6d1..00000000
--- a/home/xyz/.local/bin/curlqb
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-curl -s 'https://github.com/qbittorrent/search-plugins/wiki/Unofficial-search-plugins' | awk -F'"' '
-/require an account/ {exit}
-/\.py/ {
- url=$2
- getline
- getline
- getline
- if($0 !~ /❗|✖/)
- print url
-}
-' | xargs curl -s -Z -L --remote-name-all --create-dirs --output-dir "$1" --
-
-# an alternative awk command:
-#awk -F'"' '
-#/require an account/ {exit}
-#/\.py/ {
-# url=$2
-# line=NR
-#}
-#url && NR==line+3 && !/❗|✖/ {print url}
-#'
diff --git a/home/xyz/.local/bin/dateft b/home/xyz/.local/bin/dateft
deleted file mode 100755
index b3174749..00000000
--- a/home/xyz/.local/bin/dateft
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-# DATE From To
-
-while getopts cfF:t:T: opt; do
- case $opt in
- c) tz_from="Asia/Shanghai";;
- f) tz_from="$(tzselect)";;
- F) tz_from="$OPTARG";;
- # one extra ',' at the end will not let `for tz in ...` loop one extra time?
- t) for i in $(seq "$OPTARG"); do
- tz_to="$(tzselect),$tz_to"
- done;;
- T) tz_to="$OPTARG,$tz_to";;
- \?) exit 1;;
- esac
-done
-shift $((OPTIND-1))
-
-time_from="TZ=\"${tz_from:-$(readlink /etc/localtime | sed 's#.*/\(.*/.*\)$#\1#')}\" ${1:-now}"
-
-date -d "$time_from"
-TZ="Asia/Shanghai" date -d "$time_from"
-date -d "$time_from" -u
-date -d "$time_from" +%s
-[ "$tz_from" ] && [ "$tz_from" != "Asia/Shanghai" ] && TZ="$tz_from" date -d "$time_from"
-IFS=','
-for tz in $tz_to; do
- TZ="$tz" date -d "$time_from"
-done
diff --git a/home/xyz/.local/bin/grrc b/home/xyz/.local/bin/grrc
deleted file mode 100755
index ee8942b2..00000000
--- a/home/xyz/.local/bin/grrc
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-# GRep -R Code
-
-[ "$1" ] && find "$HOME/archive/programs/public_archive_codes" "$HOME/archive/programs/private_archive_codes" "$HOME/archive/programs/me106_proj_fall2021" "$HOME/archive/programs/car_job/av_dev" "$XDG_DOCUMENTS_DIR/notes" -mindepth 1 -maxdepth 1 -path "*/\.git" -prune -o -type d -print0 | xargs -0 grep --color=always -iIR "$@" "$HOME/.local/bin" "$HOME/.bashrc" "$HOME/.profile" "$HOME/.xinitrc" "$HOME/programs/suckless/dwm_fly/config.def.h" "$XDG_CONFIG_HOME/nsxiv/exec/key-handler" | "$PAGER"
diff --git a/home/xyz/.local/bin/il b/home/xyz/.local/bin/il
deleted file mode 100755
index 7c75a710..00000000
--- a/home/xyz/.local/bin/il
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-# InterpoLation
-
-# x=$1, xa=$2, xb=$3, ya=$4, yb=$5
-# https://en.wikipedia.org/wiki/Interpolation#Linear_interpolation
-echo "scale=4;$4+($5-$4)*($1-$2)/($3-$2)" | bc
diff --git a/home/xyz/.local/bin/mpva b/home/xyz/.local/bin/mpva
deleted file mode 100755
index d80c9f3b..00000000
--- a/home/xyz/.local/bin/mpva
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-# MPV Audio
-
-# fzf has --read0, maybe useful
-# use --loop-file for single file, better performance maybe
-# fzf --scheme=path for better fzf result when searching path, like the old time:
-# https://github.com/junegunn/fzf/commit/6fb41a202a97ad3f2437f6e5aee8890268560412
-
-if [ $# -eq 0 ]; then
- find "$XDG_MUSIC_DIR" | fzf -m --print0 --scheme=path
-fi | xargs -0 sh -c '
-if [ $# -eq 1 ] && ! [ -d "$1" ]; then
- mpv --af= --loop-file=inf --video=no "$1"
-else
- mpv --af= --shuffle --loop-playlist=inf --video=no "$@"
-fi
-' shell "$@"
diff --git a/home/xyz/.local/bin/mpvy b/home/xyz/.local/bin/mpvy
deleted file mode 100755
index 97f92ffd..00000000
--- a/home/xyz/.local/bin/mpvy
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-# MPV Yank/Youtube videos
-# references:
-# https://www.rockyourcode.com/til-how-to-watch-youtube-videos-with-mpv-and-keyboard-shortcuts/
-
-fps=30
-height=$SCR_HEIGHT
-url="$(xsel -ob)"
-flag=s
-
-# option f and h may do nothing if redownload? since same filename exist. yt-dlp won't download same file even without --auto-file-renameing=false. how improve? pass argument to aria2c?
-while getopts Aabd:f:h:su: opt; do
- case $opt in
- # s: streaming, a: aria2c then mpv, A: aria2c
- A|a|s) flag=$opt;;
- b) format='bestvideo+bestaudio/best';;
- d) download_dir="$OPTARG";;
- f) fps="$OPTARG";;
- h) height="$OPTARG";;
- u) url="$OPTARG";;
- \?) exit 1;;
- esac
-done
-if [ -z "$format" ]; then
- #vformat="[height<=?$height][fps<=?$fps][vcodec!^=?vp9][vcodec!^=?av01]"
- vformat="[height<=?$height][fps<=?$fps][vcodec!^=?av01]"
- # usually get .mp4 video + .webm audio on youtube, yt-dlp needs to merge them to .mkv
- # it used to cause problem, but I forget
- format="bestvideo$vformat+bestaudio/best$vformat"
-fi
-
-case $flag in
- # here if use --write-sub, mpv doesn't recognize subtitles?
- # --embed-subs is a little bit better, but still worse then direct streaming
- # --sponsorblock-remove will make audio/video goes out of sync, need --force-keyframes-at-cuts which need re-encode which is slow, more see comments at the bottom of https://github.com/yt-dlp/yt-dlp/issues/871
- # another way is using mpv-sponsorblock-minimal-git for streaming and sponsorblock-mpv-local for local videos
- A) yt-dlp -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove default --sponsorblock-mark default "$url";;
- a) yt-dlp -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove default --sponsorblock-mark default "$url" --exec 'mpv --fs --speed=2';;
- s) mpv --ytdl-format="$format" --ytdl-raw-options='write-sub=' --fs --speed=2 "$url";;
-esac
-# not sure if this is the best practice, but it seems working ;)
-status=$?
-[ $status -ne 0 ] && notify-send 'mpvsel failed'
-exit $status
diff --git a/home/xyz/.local/bin/mrt b/home/xyz/.local/bin/mrt
deleted file mode 100755
index b39aeaca..00000000
--- a/home/xyz/.local/bin/mrt
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/sh
-# Mullvad Relay Test
-
-# Possible reasons for not reaching baidu.com and baomitu.com:
-# https://github.com/mullvad/dns-blocklists/issues/86#issuecomment-1479102157
-# https://www.reddit.com/r/mullvadvpn/comments/10sht67/open_chinese_search_machines
-
-location="Los Angeles"
-# about 2 to 3 seconds for fast connection, 5 to 7 seconds for slow connection, to specified website
-curl_maxtime=7
-website=www.baidu.com
-
-while getopts l:m:w: opt; do
- case $opt in
- l)location="$OPTARG";;
- m)curl_maxtime="$OPTARG";;
- w)website="$OPTARG";;
- \?)exit 1;;
- esac
-done
-
-mullvad relay update
-# info gawk Node: Ranges, 7.1.3 Specifying Record Ranges with Patterns
-# https://www.baeldung.com/linux/print-lines-between-two-patterns
-# https://stackoverflow.com/q/39384283/9008720
-# https://stackoverflow.com/a/38972737/9008720
-# https://stackoverflow.com/a/17988834/9008720
-# https://unix.stackexchange.com/q/63891/459013
-# https://stackoverflow.com/a/17914105/9008720
-for relay in $(mullvad relay list | awk -v location="$location" '
-$0 ~ location {f=1;next}
-/^\t[[:alpha:]]/ {f=0}
-f {
- if($5 == "WireGuard,")
- print $1
-}'); do
- mullvad relay set hostname "$relay"
- t=0
- while [ $t -lt 30 ]; do
- if mullvad status | grep -q "Connected to $relay"; then
- if curl -Ism"$curl_maxtime" "$website"; then
- good_relays="$(printf '%s\n' "$good_relays" "$relay")"
- fi
- break
- fi
- sleep 0.1
- t=$((t+1))
- done
-done
-
-echo "$good_relays" | tee "$XDG_DOCUMENTS_DIR/logs/mrt_$(printf '%s' "$location" | tr '[:upper:] ' '[:lower:]_')_$website.log"
diff --git a/home/xyz/.local/bin/news b/home/xyz/.local/bin/news
deleted file mode 100755
index 82c47f34..00000000
--- a/home/xyz/.local/bin/news
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-daily () {
- # maybe add: https://discord.com/channels/@me
- o "$BROWSER" https://github.com/notifications https://mail.google.com 'https://mail.google.com/mail/u/0/#spam'
- # alacritty --hold must be before -e
- # full window: -w156, am and pm in one line: -w114
- o alacritty --hold -e rem -cu+2 -@ -w114
- o alacritty --hold -e wtr
- o alacritty -e newsboat
- o alacritty -e weechat
- o telegram-desktop
-}
-
-monthly () {
- o alacritty --hold -e rate
- o "$BROWSER" --new-window https://smtp.cheogram.com/
-}
-
-if [ $# -eq 0 ]; then
- daily
-else
- while getopts m opt; do
- case $opt in
- m) monthly;;
- \?) exit 1;;
- esac
- done
-fi
diff --git a/home/xyz/.local/bin/rate b/home/xyz/.local/bin/rate
deleted file mode 100755
index 1625df62..00000000
--- a/home/xyz/.local/bin/rate
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-while getopts f:t: opt; do
- case $opt in
- f) from="$OPTARG";;
- t) to="$(echo "$OPTARG" | tr '[:lower:]' '[:upper:]')";;
- \?) exit 1;;
- esac
-done
-# https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates
-curl -s "https://api.coinbase.com/v2/exchange-rates?currency=${from:-xmr}" | jq -r ".data.rates.${to:-USD}"
diff --git a/home/xyz/.local/bin/reco b/home/xyz/.local/bin/reco
deleted file mode 100755
index 7ee726d2..00000000
--- a/home/xyz/.local/bin/reco
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-
-# useful urls:
-# https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/dmenurecord
-# https://wiki.archlinux.org/title/FFmpeg#Screen_capture
-# https://trac.ffmpeg.org/wiki/Capture/Desktop
-
-infofile="/tmp/recoinfo"
-recodir="$XDG_VIDEOS_DIR/recordings/"
-tmpdir="$recodir/tmp/"
-mkdir -p "$recodir" "$tmpdir"
-
-if [ -e "$infofile" ]; then
- read -r pid tmpfile < "$infofile"
- kill "$pid"
- notify-send 'finish recording, start converting'
- ffmpeg -i "$tmpfile" "$recodir/$(time-uuid).mkv"
- notify-send 'finish converting'
- rm "$tmpfile" "$infofile"
-else
- tmpfile="$tmpdir/$(time-uuid).mkv"
- notify-send 'prepare recording'
- # arch wiki way, no audio, less cpu use during capturing (fast?), large file size, need convert afterward
- xrectsel '%w %h %x %y' | xargs sh -c 'ffmpeg -y -loglevel quiet -f x11grab -framerate 25 -s "$2x$3" -i "$DISPLAY+$4,$5" -c:v ffvhuff "$1" & echo $!' shell "$tmpfile" | xargs -I {} printf '%s\t%s' '{}' "$tmpfile" > "$infofile"
- # another way to get subshell ffmpeg child pid
- #xrectsel '%w %h %x %y' | xargs sh -c 'ffmpeg -y -f x11grab -framerate 25 -s "$2x$3" -i "$DISPLAY+$4,$5" -c:v ffvhuff "$1"' shell "$tmpfile" &
- #printf '%s\t%s' "$(ps -o pid= --ppid $!)" "$tmpfile" > "$infofile"
-fi
diff --git a/home/xyz/.local/bin/sbar b/home/xyz/.local/bin/sbar
deleted file mode 100755
index 461d83ac..00000000
--- a/home/xyz/.local/bin/sbar
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/sh
-# modified from pystardust, GPLv3 license: https://github.com/pystardust/sbar
-
-# INIT
-sec=0
-
-# MODULES
-update_time () {
- time="$(date '+%a %m/%d %H:%M') $(TZ=Asia/Shanghai date '+/%d %H:') $(date -u '+/%d %H:')"
-}
-
-#update_cap () {
-# cap="$(if xset q | grep -q "Caps Lock: *on"; then echo A; else echo a; fi)"
-#}
-
-update_net () {
- net="$(if nmcli -t --fields type,state device | grep -q '\(ethernet\|wifi\):connected'; then echo 1; else echo 0; fi)"
- vpn="$(if nmcli -t --fields type,state device | grep -q '\(tun\|wireguard\):connected'; then echo 1; else echo 0; fi)"
-}
-
-update_vol () {
- # $(NF-1) for both alsa and pulseaudio
- vol="$(amixer get Master | awk -F'[][]' 'END{printf("%d %s",($(NF-1)=="on")?1:0,$2)}')"
-}
-
-update_mic () {
- # $(NF-1) for both alsa and pulseaudio
- mic="$(amixer get Capture | awk -F '[][]' 'END{print ($(NF-1)=="on")?1:0}')"
-}
-
-update_bat () {
- bat="$(cat /sys/class/power_supply/BAT0/capacity)%"
-}
-
-update_gpu () {
- gpu="$(envycontrol -q | awk 'END{print toupper(substr($NF,0,1))}')"
-}
-
-display () {
- xsetroot -name "$time | N $net V $vpn | M $vol C $mic | $gpu | $bat"
-}
-
-# modules that don't update on their own need to be run at the start for getting their initial value
-update_net
-update_vol
-update_mic
-update_gpu
-
-# SIGNALLING
-# trap "<function>;display" "RTMIN+n"
-trap "update_mic;display" "RTMIN"
-trap "update_vol;display" "RTMIN+1"
-# xev can't read my toggle internet keyboard key, don't know what key to use in sxhkd to send signal
-trap "update_net;display" "RTMIN+2"
-# to update it from external commands
-## kill -m $(pidof -x sbar)
-# where m = 34 + n
-
-while :; do
- sleep 1 &
- wait
- [ $((sec % 5 )) -eq 0 ] && update_time # update time every 5 seconds
- [ $((sec % 60)) -eq 0 ] && update_net
- [ $((sec % 60)) -eq 0 ] && update_bat
- # how often the display updates ( 5 seconds )
- [ $((sec % 5 )) -eq 0 ] && display
- sec=$((sec + 1))
-done
diff --git a/home/xyz/.local/bin/ta b/home/xyz/.local/bin/ta
deleted file mode 100755
index ae386c11..00000000
--- a/home/xyz/.local/bin/ta
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-# TIme Alarm
-
-time -p "$@"
-o alarm 0 'Command Finished' "$(/usr/bin/printf '%q ' "$@")"
diff --git a/home/xyz/.local/bin/topa b/home/xyz/.local/bin/topa
deleted file mode 100755
index 32529979..00000000
--- a/home/xyz/.local/bin/topa
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-o alacritty -e htop
-#o alacritty -e radeontop -c
-o alacritty -e iotop
-o alacritty -e nethogs
-o alacritty -e intel_gpu_top
-o alacritty -e nvtop
diff --git a/home/xyz/.local/bin/zoom b/home/xyz/.local/bin/zoom
deleted file mode 120000
index c81c2c75..00000000
--- a/home/xyz/.local/bin/zoom
+++ /dev/null
@@ -1 +0,0 @@
-/usr/bin/zoom-firejail \ No newline at end of file