diff options
Diffstat (limited to 'home/xyz/.local')
-rwxr-xr-x | home/xyz/.local/bin/alacritty | 4 | ||||
-rwxr-xr-x | home/xyz/.local/bin/alarm | 9 | ||||
-rwxr-xr-x | home/xyz/.local/bin/bell | 7 | ||||
-rwxr-xr-x | home/xyz/.local/bin/ccgsl | 7 | ||||
-rwxr-xr-x | home/xyz/.local/bin/convwall | 34 | ||||
-rwxr-xr-x | home/xyz/.local/bin/curlkg | 52 | ||||
-rwxr-xr-x | home/xyz/.local/bin/curlncm | 75 | ||||
-rwxr-xr-x | home/xyz/.local/bin/curlqb | 13 | ||||
-rwxr-xr-x | home/xyz/.local/bin/mpva | 15 | ||||
-rwxr-xr-x | home/xyz/.local/bin/mpvy | 41 | ||||
-rwxr-xr-x | home/xyz/.local/bin/news | 10 | ||||
-rwxr-xr-x | home/xyz/.local/bin/reco | 28 | ||||
-rwxr-xr-x | home/xyz/.local/bin/sbar | 65 | ||||
-rwxr-xr-x | home/xyz/.local/bin/shufwall | 9 | ||||
-rwxr-xr-x | home/xyz/.local/bin/topa | 6 | ||||
l--------- | home/xyz/.local/bin/zoom | 1 | ||||
-rw-r--r-- | home/xyz/.local/share/applications/file.desktop | 4 |
17 files changed, 0 insertions, 380 deletions
diff --git a/home/xyz/.local/bin/alacritty b/home/xyz/.local/bin/alacritty deleted file mode 100755 index 64cedfcc..00000000 --- a/home/xyz/.local/bin/alacritty +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# https://github.com/MithicSpirit/dotfiles/blob/master/.local/bin/alacritty -/usr/bin/alacritty msg create-window "$@" || /usr/bin/alacritty "$@" diff --git a/home/xyz/.local/bin/alarm b/home/xyz/.local/bin/alarm deleted file mode 100755 index 9b366e19..00000000 --- a/home/xyz/.local/bin/alarm +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -printf 'notify-send -u critical "%s"; bell' "${2:-alarm}" | at now + "$1" minutes && 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/bell b/home/xyz/.local/bin/bell deleted file mode 100755 index c8bebd5e..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 20% -# 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/convwall b/home/xyz/.local/bin/convwall deleted file mode 100755 index dff9c43b..00000000 --- a/home/xyz/.local/bin/convwall +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -# target image aspect ratio -wratio=$SCR_WIDTH -hratio=$SCR_HEIGHT -# chop how much from center -chopnum=99% - -# my benchmark shows -ping is much faster than default -# https://github.com/ImageMagick/ImageMagick/issues/3183#issuecomment-800955241 -width=$(identify -ping -format '%w' "$1") -height=$(identify -ping -format '%h' "$1") - -ratio=$((wratio*100/hratio)) -dim=$((width*100/height)) - -if [ "$dim" -ne "$ratio" ]; then - if [ "$dim" -lt "$ratio" ]; then - chopgeom="${chopnum}x0" - width=$((height*wratio/hratio)) - else - chopgeom="0x$chopnum" - height=$((width*hratio/wratio)) - fi - # may throw error "sort: write failed: 'standard output': Broken pipe \n sort: write error" - # caused by head exit (or close stdin) before sort output complete, can ignore - # https://stackoverflow.com/questions/46202653/bash-error-in-sort-sort-write-failed-standard-output-broken-pipe - bgcolor=$(convert "$1" -gravity center -chop "$chopgeom" -define histogram:unique-colors=true -format %c histogram:info:- | sort -rn | head -n1 | awk \{print\ \$3\} | cut -c1-7) - # another approach is to use "$width" or "x$height" for geometry, current approach is more readable - convert "$1" -gravity center -background "$bgcolor" -extent "${width}x$height" "$2" -else - echo 'same aspect ratio, no need to convert' >&2 - exit 1 -fi diff --git a/home/xyz/.local/bin/curlkg b/home/xyz/.local/bin/curlkg deleted file mode 100755 index 4276e820..00000000 --- a/home/xyz/.local/bin/curlkg +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -# references: -# https://blog.csdn.net/qq_41730930/article/details/79327757 -# https://blog.csdn.net/u011112876/article/details/89634505 -# https://github.com/pystardust/ytfzf - -homepage_url='https://node.kg.qq.com/cgi/fcgi-bin/kg_ugc_get_homepage' -music_url='https://node.kg.qq.com/cgi/fcgi-bin/fcg_get_play_url' -# num seems only 8 and 15 works -num=15 -tmp_file="$(mktemp)" - -get_json () { - curl -s -G --data-urlencode type=get_uinfo -d outCharset=utf-8 -d start="$1" -d num=$num -d share_uid="$uid" "$homepage_url" | sed 's/.*({\(.*\)}).*/{\1}/' -} - -# concurrent file append with less than 4096 bytes will be atomic on arch linux ext4 -# so need to process json data before append to the file, to append less than 4096 bytes for each process -# another appraoch is to use a loop to write to several files each corresponding to one process -# https://stackoverflow.com/questions/1154446/is-file-append-atomic-in-unix -# https://unix.stackexchange.com/questions/458653/parallel-processes-appending-outputs-to-an-array-in-a-bash-script -process_json() { - jq -r '.data.ugclist[]|"'"$music_url"'?shareid=\(.shareid)\n out=\(.title)_\(.time).m4a"' >> "$tmp_file" -} - -while getopts u: opt; do - case $opt in - u) uid="$OPTARG";; - \?) exit 1;; - esac -done -# for lan lan, uid=649b9e82272a348b -# for cheng ruan, uid=64949d822c25328c -[ -z "$uid" ] && echo 'error: must provide share_uid -ex: curlkg -u 649b9e82272a348b ./' >&2 && exit 1 -shift $((OPTIND-1)) -download_dir="${1:-"$PWD"}" -[ -d "$download_dir" ] || mkdir -p "$download_dir" - -first_json="$(get_json 1)" -ugc_total_count=$(echo "$first_json" | jq '.data.ugc_total_count') -echo "$first_json" | process_json -# can also use while loop with i=$((i+1)) -# the calculation considers both ugc_total_count%num==0 and ugc_total_count%num>0 -for i in $(seq 2 $(((ugc_total_count+num-1)/num))); do - get_json "$i" | process_json & -done - -wait -aria2c -d "$download_dir" --auto-file-renaming=false --console-log-level=warn -i "$tmp_file" -rm "$tmp_file" diff --git a/home/xyz/.local/bin/curlncm b/home/xyz/.local/bin/curlncm deleted file mode 100755 index 25f39aa9..00000000 --- a/home/xyz/.local/bin/curlncm +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -# rewrite TianyiShi2001's python script which rewrite NeteaseCloudMusicApi node.js api - -# references: -# https://github.com/ytdl-org/youtube-dl/issues/18051#issuecomment-859964832 -# https://github.com/Binaryify/NeteaseCloudMusicApi -# info about encrytion and api: -# https://github.com/metowolf/NeteaseCloudMusicApi/wiki -# https://github.com/darknessomi/musicbox/wiki - -# lan lan, aid=48860966, rid=793052426, example id=1397315179,1817498734 -# cheng ruan, aid=46703185, rid=792968433 - -# trial and error to get dj_max, don't know why, maybe because it is 2^31 and it is the size limit of whatever type of the variable -dj_max=2147483647 -dl_urls_tmp="$(mktemp)" -# printf 'e82ckenh8dichen8' | hexdump -ve '/1 "%02x"' -key='653832636b656e683864696368656e38' -url='/api/song/enhance/player/url' -request_id=$(date +'%s%3N')_$(seq -w 1 1000 | shuf -n1) -user_agent='Mozilla/5.0 (Linux; U; Android 9; zh-cn; Redmi Note 8 Build/PKQ1.190616.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/71.0.3578.141 Mobile Safari/537.36 XiaoMi/MiuiBrowser/12.5.22' -cookie="$(printf '"appver":"8.0.0","versioncode":"140","buildver":"1623455100","resolution":"1920x1080","__csrf":"","os":"pc","requestId":"%s"' "$request_id")" - -die () { - echo "error: $*" >&2 - exit 1 -} - -# artist, song, djradio id -while getopts a:i:r: opt; do - case $opt in - a) aid="$OPTARG";; - i) ids="$OPTARG";; - r) rid="$OPTARG";; - \?) exit 1;; - esac -done -shift $((OPTIND-1)) -download_dir="${1:-"$PWD"}" -[ -d "$download_dir" ] || mkdir -p "$download_dir" - -if [ "$ids" ]; then - # temporary solution, can improve by auto curl names - data="$(echo "$ids" | tr ',' '\n' | awk '{printf("%s\t%s\n",$0,"songname")}')" -else - if [ "$rid" ]; then - data="$(curl -s -G --data-urlencode id="$rid" -d limit="$dj_max" 'https://music.163.com/djradio' | grep 'songlist\|tt f-thide' | sed -e 's/.*songlist-\(.*\)" class.*/\1/g' -e 's/.*title="\(.*\)".*/\1/g' | paste -sd '\t\n' | sort | tr '/' '_')" - # can only curl featured 50 songs for the artist, can improve - elif [ "$aid" ]; then - data="$(curl -s -G --data-urlencode id="$aid" 'https://music.163.com/artist' | grep '\[{.*}\]' | sed -e 's/.*>\[{/\[{/' -e 's/}\]<.*/}\]/' | jq -r '.[]|[.id,.name]|@tsv' | sort | tr '/' '_')" - fi - # awk code not print separator at beginning and end steal from: - # https://unix.stackexchange.com/a/581785/459013 - # not sure awk one-liner or paste way which is better, need benchmark - ids="$(echo "$data" | awk -F'\t' '{printf "%s%s",sep,$1;sep=","}')" - #ids="$(echo "$data" | awk -F'\t' '{print $1}' | paste -sd ',')" -fi - -# I don't fully understand following several lines of code -# I rewrite TianyiShi2001's python script, he rewrites NeteaseCloudMusicApi -text="$(printf '{"ids":"[%s]","br":999000,"header":{%s}}' "$ids" "$cookie")" -message="nobody${url}use${text}md5forencrypt" -digest="$(printf '%s' "$message" | openssl dgst -md5 -hex | awk '{print $2}')" -params="$(printf '%s-36cd479b6b5-%s-36cd479b6b5-%s' "$url" "$text" "$digest")" -encrypted_params="$(printf '%s' "$params" | openssl enc -aes-128-ecb -K "$key" | hexdump -ve '/1 "%02X"')" -# curl default user agent header seems not working -curl -s -A "$user_agent" -d params="$encrypted_params" 'https://interface3.music.163.com/eapi/song/enhance/player/url' | jq -r '.data|sort_by(.id)|.[].url' > "$dl_urls_tmp" -[ "$(echo "$data" | wc -l)" -ne "$(wc -l < "$dl_urls_tmp")" ] && die "number of download urls doesn't match request" - -# can't download some music if live abroad, may need proxy or vpn -# using user_agent, content-type header, cookie header, referer are not necessary? but feels faster -# not sure about cookie header format for aria2c, this link shows that it's kinda messy, so I didn't use it -# https://github.com/aria2/aria2/issues/545#issuecomment-650070869 -echo "$data" | awk -F'\t' '{printf(" out=%s_%s.mp3\n",$2,$1)}' | paste "$dl_urls_tmp" - -d '\n' | aria2c -U "$user_agent" --header='Content-Type: application/x-www-form-urlencoded' --referer='https://music.163.com' -d "$download_dir" --auto-file-renaming=false --console-log-level=warn -i- -rm "$dl_urls_tmp" diff --git a/home/xyz/.local/bin/curlqb b/home/xyz/.local/bin/curlqb deleted file mode 100755 index c3f6871b..00000000 --- a/home/xyz/.local/bin/curlqb +++ /dev/null @@ -1,13 +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" -- diff --git a/home/xyz/.local/bin/mpva b/home/xyz/.local/bin/mpva deleted file mode 100755 index a54dfa99..00000000 --- a/home/xyz/.local/bin/mpva +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# MPV Audio - -# fzf has --read0, maybe useful -# use --loop-file for single file, better performance maybe - -if [ $# -eq 0 ]; then - find "$XDG_MUSIC_DIR" | fzf -m --print0 -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 880d1ffa..00000000 --- a/home/xyz/.local/bin/mpvy +++ /dev/null @@ -1,41 +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]" - # 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 - A) yt-dlp -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove all "$url";; - a) yt-dlp -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove all "$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/news b/home/xyz/.local/bin/news deleted file mode 100755 index bfcf283f..00000000 --- a/home/xyz/.local/bin/news +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -o "$BROWSER" github.com/notifications mail.google.com -# --hold must be before -e -# full window: -w156, am and pm in one line: -w114 -o alacritty --hold -e rem -c+2 -@ -w114 -o alacritty --hold -e wtr -o alacritty -e newsboat -o alacritty -e weechat -o telegram-desktop diff --git a/home/xyz/.local/bin/reco b/home/xyz/.local/bin/reco deleted file mode 100755 index 068e6ad8..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 19789091..00000000 --- a/home/xyz/.local/bin/sbar +++ /dev/null @@ -1,65 +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:')" -} - -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: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/BAT1/capacity)%" -} - -display () { - xsetroot -name "$time | N $net V $vpn | M $vol C $mic | $cap | $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 - -# 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" -trap "update_cap;display" "RTMIN+3" -# 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 - update_cap - [ $((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/shufwall b/home/xyz/.local/bin/shufwall deleted file mode 100755 index 5b249e12..00000000 --- a/home/xyz/.local/bin/shufwall +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -if [ -z "$1" ]; then - file=$(find -L "$XDG_PICTURES_DIR/wallpapers" -type f | shuf -n 1) -else - file=$(find -L "$@" -maxdepth 1 -type f | shuf -n 1) -fi - -display -resize "${SCR_WIDTH}x$SCR_HEIGHT" -backdrop -window root "$file" diff --git a/home/xyz/.local/bin/topa b/home/xyz/.local/bin/topa deleted file mode 100755 index e921bc31..00000000 --- a/home/xyz/.local/bin/topa +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -o alacritty -e htop -o alacritty -e radeontop -c -o alacritty -e sudo iotop -o alacritty -e sudo nethogs 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 diff --git a/home/xyz/.local/share/applications/file.desktop b/home/xyz/.local/share/applications/file.desktop deleted file mode 100644 index 5429fcc7..00000000 --- a/home/xyz/.local/share/applications/file.desktop +++ /dev/null @@ -1,4 +0,0 @@ -[Desktop Entry] -Type=Application -Name=File Manager -Exec=alacritty --working-directory %u |