summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiao Pan <gky44px1999@gmail.com>2023-02-09 16:39:54 -0800
committerXiao Pan <gky44px1999@gmail.com>2023-02-09 16:39:54 -0800
commit23ed1ac135e4b31933d0fd926e96c85f12d7f44b (patch)
tree3766b636f193d77f2835caf66dea8142e8d8b3eb
parent7c7535db00a4f0f7019e2c9585c0c108ebca3e3d (diff)
debloat
-rw-r--r--home/xyz/.config/myconf/gallery_urls5
-rwxr-xr-xhome/xyz/.local/bin/convwall35
-rwxr-xr-xhome/xyz/.local/bin/curlkg52
-rwxr-xr-xhome/xyz/.local/bin/curlncm75
-rwxr-xr-xhome/xyz/.local/bin/matlab31
-rwxr-xr-xhome/xyz/.local/bin/shufwall9
-rwxr-xr-xhome/xyz/.local/bin/upd27
-rw-r--r--home/xyz/.xinitrc6
8 files changed, 1 insertions, 239 deletions
diff --git a/home/xyz/.config/myconf/gallery_urls b/home/xyz/.config/myconf/gallery_urls
deleted file mode 100644
index 0f128ec3..00000000
--- a/home/xyz/.config/myconf/gallery_urls
+++ /dev/null
@@ -1,5 +0,0 @@
-# input file format see https://github.com/mikf/gallery-dl/blob/13d4045a8a5a6fd45cb20df399f44055b25f5cca/gallery_dl/__init__.py#L33-L58
-#https://www.pixiv.net/users/13379747/artworks
-https://www.deviantart.com/wlop/gallery
-https://www.deviantart.com/minimalistic-animoo/gallery/
-https://www.deviantart.com/theminimalists/gallery/
diff --git a/home/xyz/.local/bin/convwall b/home/xyz/.local/bin/convwall
deleted file mode 100755
index 8efd1368..00000000
--- a/home/xyz/.local/bin/convwall
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-# CONVert WALLpaper
-
-# 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/matlab b/home/xyz/.local/bin/matlab
deleted file mode 100755
index 9df9e996..00000000
--- a/home/xyz/.local/bin/matlab
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-# for matlab version R2022a
-# https://wiki.archlinux.org/title/MATLAB#Blank/grey_UI_when_using_WM_(non-reparenting_window_manager)
-# https://wiki.archlinux.org/title/Java#Gray_window,_applications_not_resizing_with_WM,_menus_immediately_closing
-# https://wiki.archlinux.org/title/MATLAB#Unable_to_launch_the_MATLABWindow_application
-# https://faq.i3wm.org/question/2564/cant-open-matlab-from-dmenu.1.html
-# https://wiki.archlinux.org/title/MATLAB#Desktop_entry
-# use /tmp as working (startup) directory and save simulink files there to avoid cross filesystem hardlink error:
-# https://bbs.archlinux.org/viewtopic.php?id=277970
-
-cmd () {
- _JAVA_AWT_WM_NONREPARENTING=1 LD_PRELOAD=/lib64/libfreetype.so exec "$bin_dir/matlab" -sd "$startup_dir" -desktop -nosplash "$@"
-}
-
-startup_dir=/tmp/matlab
-bin_dir="$HOME/programs/MATLAB/R2022a/bin"
-addon_dir="$HOME/MATLAB Add-Ons"
-[ -d "$startup_dir" ] || mkdir "$startup_dir"
-
-# my workaround for simulink gyroscope compile errors:
-# "avr-gcc: error: I2Cdev.o: No such file or directory" (also for other .o files)
-# "Code generation information file does not exist." (caused by no .o file error before I guess)
-# I guess it is still cross filesystem hardlink error
-# need to set path in matlab manually once for "$startup_dir/$addon_dir" sub dirs inside
-[ -d "$startup_dir/$addon_dir" ] || cp -r "$addon_dir" "$startup_dir"
-
-if ! cmd "$@"; then
- "$bin_dir/activate_matlab.sh"
- cmd "$@"
-fi
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/upd b/home/xyz/.local/bin/upd
index 3c3a8536..c545ec98 100755
--- a/home/xyz/.local/bin/upd
+++ b/home/xyz/.local/bin/upd
@@ -3,10 +3,7 @@
all () {
fast
qb
- #kg
- #ncm
refl
- #gall
usb
xmr
}
@@ -40,21 +37,12 @@ fast () {
misc
}
-gall () {
- gallery-dl --download-archive "$XDG_DOCUMENTS_DIR/database/gallery-dl.sqlite3" -d "$XDG_PICTURES_DIR/anime/gallery-dl/" -i "$XDG_CONFIG_HOME/myconf/gallery_urls"
-}
-
userjs () {
kill $(pidof "$BROWSER")
"$HOME/.mozilla/firefox/xxxxxxxx.fly/prefsCleaner.sh" -s
"$HOME/.mozilla/firefox/xxxxxxxx.fly/updater.sh" -us
}
-kg () {
- curlkg -u649b9e82272a348b -- "$XDG_MUSIC_DIR/lan_lan/kg/"
- #curlkg -u64949d822c25328c -- "$XDG_MUSIC_DIR/cheng_ruan/kg/"
-}
-
misc () {
"$EDITOR" +PlugUpgrade +PlugClean! +PlugUpdate +qa
tldr --update
@@ -69,16 +57,6 @@ misc () {
clean
}
-ncm () {
- curlncm -a48860966 -- "$XDG_MUSIC_DIR/lan_lan/ncm/artist/"
- #curlncm -a46703185 -- "$XDG_MUSIC_DIR/cheng_ruan/ncm/artist/"
- #curlncm -a30382647 -- "$XDG_MUSIC_DIR/qi_tian_sakura/ncm/artist/"
-
- curlncm -r793052426 -- "$XDG_MUSIC_DIR/lan_lan/ncm/djradio/"
- #curlncm -r792968433 -- "$XDG_MUSIC_DIR/cheng_ruan/ncm/djradio/"
- #curlncm -r792042397 -- "$XDG_MUSIC_DIR/qi_tian_sakura/ncm/djradio/"
-}
-
pac () {
pacpacs="$(sudo pacman --noconfirm -Syu | tee /dev/tty | grep '^Packages' | cut -d' ' -f3-)"
aurpacs="$(paru --noconfirm -aSu | tee /dev/tty | grep '^Aur' | cut -d' ' -f3-)"
@@ -132,16 +110,13 @@ xmr () {
if [ $# -eq 0 ]; then
fast
else
- while getopts acfgjkmnpqrux opt; do
+ while getopts acfjmpqrux opt; do
case $opt in
a)all;;
c)clean;;
f)fast;;
- g)gall;;
j)userjs;;
- k)kg;;
m)misc;;
- n)ncm;;
p)pac;;
q)qb;;
r)refl;;
diff --git a/home/xyz/.xinitrc b/home/xyz/.xinitrc
index 4722f960..2fb8a47b 100644
--- a/home/xyz/.xinitrc
+++ b/home/xyz/.xinitrc
@@ -32,12 +32,6 @@ if [ -d /etc/X11/xinit/xinitrc.d ] ; then
unset f
fi
-#if [ -e "$XDG_PICTURES_DIR/wallpapers/wallpaper" ]; then
-# display -window root "$XDG_PICTURES_DIR/wallpapers/wallpaper" &
-#else
-# shufwall &
-#fi
-
#clipmenud &
fcitx5 -d
redshift &