diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/battery | 6 | ||||
| -rwxr-xr-x | scripts/cpu-vulns | 2 | ||||
| -rwxr-xr-x | scripts/dbus-sway-environment | 5 | ||||
| -rwxr-xr-x | scripts/discord-wayland | 2 | ||||
| -rwxr-xr-x | scripts/dmenu-emoji | 2 | ||||
| -rwxr-xr-x | scripts/dmenu-path | 3 | ||||
| -rwxr-xr-x | scripts/gpg-pubkey | 2 | ||||
| -rwxr-xr-x | scripts/img-fstype | 2 | ||||
| -rwxr-xr-x | scripts/moonrune-charset-utf8 | 6 | ||||
| -rwxr-xr-x | scripts/mount-nfs | 2 | ||||
| -rwxr-xr-x | scripts/rewrite-git | 8 | ||||
| -rwxr-xr-x | scripts/screenshot | 48 | ||||
| -rwxr-xr-x | scripts/shift-jis-zip | 2 | ||||
| -rwxr-xr-x | scripts/spell | 2 | ||||
| -rwxr-xr-x | scripts/term-font-size | 20 | ||||
| -rwxr-xr-x | scripts/ts-date | 2 | ||||
| -rwxr-xr-x | scripts/wlsunset-toggle | 10 | ||||
| -rwxr-xr-x | scripts/xbox360-ffmpeg-enc | 2 |
18 files changed, 126 insertions, 0 deletions
diff --git a/scripts/battery b/scripts/battery new file mode 100755 index 0000000..c09992a --- /dev/null +++ b/scripts/battery @@ -0,0 +1,6 @@ +#! /usr/bin/env sh +shopt -s nullglob +for bat in /sys/class/power_supply/BAT* +do +cat $bat/{capacity,status} +done diff --git a/scripts/cpu-vulns b/scripts/cpu-vulns new file mode 100755 index 0000000..e55ad9c --- /dev/null +++ b/scripts/cpu-vulns @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +tail -n +1 /sys/devices/system/cpu/vulnerabilities/* diff --git a/scripts/dbus-sway-environment b/scripts/dbus-sway-environment new file mode 100755 index 0000000..249d610 --- /dev/null +++ b/scripts/dbus-sway-environment @@ -0,0 +1,5 @@ +#! /usr/bin/env sh + +dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK +systemctl --user stop pipewire{,-pulse}.{socket,service} xdg-desktop-portal xdg-desktop-portal-wlr +systemctl --user start pipewire{,-pulse}.{socket,service} xdg-desktop-portal xdg-desktop-portal-wlr diff --git a/scripts/discord-wayland b/scripts/discord-wayland new file mode 100755 index 0000000..ec8a106 --- /dev/null +++ b/scripts/discord-wayland @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +discord --ignore-gpu-blocklist --enable-features=UseOzonePlatform --ozone-platform=wayland --enable-features=VaapiVideoDecoder --use-gl=desktop --enable-gpu-rasterization --enable-zero-copy diff --git a/scripts/dmenu-emoji b/scripts/dmenu-emoji new file mode 100755 index 0000000..07c1900 --- /dev/null +++ b/scripts/dmenu-emoji @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +jq -r ".[] | .emoji + \" \" + (.aliases[0])" /etc/emoji.json diff --git a/scripts/dmenu-path b/scripts/dmenu-path new file mode 100755 index 0000000..c353c0d --- /dev/null +++ b/scripts/dmenu-path @@ -0,0 +1,3 @@ +#! /usr/bin/env sh +# https://github.com/ema/dotfiles/blob/fb7f5cab530daba74edefb9cecb401262db063a9/bin/dmenu_path +echo $PATH | tr ':' '\n' | uniq | sed 's#$#/#' | xargs ls -Llu --time-style=+%s | awk '/^(-|l)/ { print $6, $7 }' | sort -rn | cut -d' ' -f 2 diff --git a/scripts/gpg-pubkey b/scripts/gpg-pubkey new file mode 100755 index 0000000..5353972 --- /dev/null +++ b/scripts/gpg-pubkey @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +gpg --export -a "Andrew Opalach <andrew@akon.city>" diff --git a/scripts/img-fstype b/scripts/img-fstype new file mode 100755 index 0000000..82df6b8 --- /dev/null +++ b/scripts/img-fstype @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +blkid -o value -s TYPE $1 diff --git a/scripts/moonrune-charset-utf8 b/scripts/moonrune-charset-utf8 new file mode 100755 index 0000000..d3e8343 --- /dev/null +++ b/scripts/moonrune-charset-utf8 @@ -0,0 +1,6 @@ +#! /usr/bin/env bash +if [[ "$1" == "china"]]; then + iconv -f GBK -t UTF8 "$2" -o "$3" +elif [[ "$1" == "jp"]]; then + iconv -f SHIFT-JIS -t UTF8 "$2" -o "$3" +fi diff --git a/scripts/mount-nfs b/scripts/mount-nfs new file mode 100755 index 0000000..c794ee4 --- /dev/null +++ b/scripts/mount-nfs @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +sudo mount -t nfs4 -o noatime,nodiratime,rw,bg,hard,intr,rsize=16384,wsize=16384,tcp,timeo=600,retrans=2,nfsvers=4.1 moyo:$1 $2 diff --git a/scripts/rewrite-git b/scripts/rewrite-git new file mode 100755 index 0000000..b48ba4d --- /dev/null +++ b/scripts/rewrite-git @@ -0,0 +1,8 @@ +#! /usr/bin/env sh +git filter-branch --commit-filter ' + GIT_AUTHOR_NAME="Andrew Opalach"; + GIT_AUTHOR_EMAIL="andrew@akon.city"; + GIT_COMMITTER_NAME="Andrew Opalach"; + GIT_COMMITTER_EMAIL="andrew@akon.city"; + git commit-tree -S "$@"; +' HEAD diff --git a/scripts/screenshot b/scripts/screenshot new file mode 100755 index 0000000..ddeb73a --- /dev/null +++ b/scripts/screenshot @@ -0,0 +1,48 @@ +#! /usr/bin/env bash + +if [[ $1 == "qrcode" || $1 == "color" ]]; then + mime_type="text/plain" +else + dir="$HOME/pics/screenshots/`date +'%m-%Y'`" + if [ ! -d $dir ]; then mkdir -p $dir; fi + while : ; do + filename="screenshot-`date +'%m-%d-%y'`-`hexdump -n 3 -e '1/4 "%02X"' /dev/random`" + [ -e $dir/$filename.* ] || break + done + if [[ $1 == "video" ]]; then + output="$dir/$filename"".mkv" + mime_type="video/x-matroska" + else + output="$dir/$filename"".png" + mime_type="image/png" + fi +fi + +parseqr () { zbarimg -q1 - | cut -d ':' -f 2-; } +parsecolor () { magick - -format '%[pixel:p{0,0}]' txt:- | awk 'END {printf $3}'; } + +if [[ $XDG_SESSION_TYPE == "wayland" ]]; then + copy="wl-copy -t $mime_type" + case $1 in + "qrcode") grim -t png -g "$(slurp)" - | parseqr | $copy ;; + "color") grim -t ppm -g "$(slurp -p)" - | parsecolor | $copy ;; + "video") wf-recorder -a -g "$(slurp)" -f $output ;; + "main") grim -t png -o DP-1 $output ;; + "full") grim -t png $output ;; + "output") grim -t png -g "$(slurp -o)" $output ;; + *) grim -t png -g "$(slurp)" $output ;; + esac +else + copy="xclip -selection clipboard -target $mime_type -i" + case $1 in + "full") import -window root $output ;; + *) + area=$(slop -f "%g") || exit 1 + read -r G < <(echo $area) + import -window root -crop $G $output ;; + esac +fi + +if [[ $1 != "qrcode" && $1 != "color" && $1 != "video" && -f $output ]]; then + cat $output | $copy; +fi diff --git a/scripts/shift-jis-zip b/scripts/shift-jis-zip new file mode 100755 index 0000000..30dab2e --- /dev/null +++ b/scripts/shift-jis-zip @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +unzip -O shift-jis "$1" diff --git a/scripts/spell b/scripts/spell new file mode 100755 index 0000000..42e1f99 --- /dev/null +++ b/scripts/spell @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +echo "$@" | aspell -a diff --git a/scripts/term-font-size b/scripts/term-font-size new file mode 100755 index 0000000..0637b12 --- /dev/null +++ b/scripts/term-font-size @@ -0,0 +1,20 @@ +#! /usr/bin/env python3 + +import array +import fcntl +import termios +import os + +def get_term_res(): + buf = array.array('H', [0, 0, 0, 0]) + fcntl.ioctl(1, termios.TIOCGWINSZ, buf) + return buf[2], buf[3] + +def get_term_dimensions(): + return os.get_terminal_size() + +x_px, y_px = get_term_res() +size = get_term_dimensions() +x_cell, y_cell = size.columns, size.lines + +print('width : {}, height: {}'.format(x_px / float(x_cell), y_px / float(y_cell))) diff --git a/scripts/ts-date b/scripts/ts-date new file mode 100755 index 0000000..f16517f --- /dev/null +++ b/scripts/ts-date @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +date -d @$1 diff --git a/scripts/wlsunset-toggle b/scripts/wlsunset-toggle new file mode 100755 index 0000000..7dcd06e --- /dev/null +++ b/scripts/wlsunset-toggle @@ -0,0 +1,10 @@ +#! /usr/bin/env sh +# <LAT>|<LONG> +CORDS=$(cat $HOME/.config/home-cords || echo '') +LAT=$(echo $CORDS | cut -d '|' -f 1) +LONG=$(echo $CORDS | cut -d '|' -f 2) +if pidof wlsunset; then + pkill wlsunset +else + wlsunset -l $LAT -L $LONG & +fi diff --git a/scripts/xbox360-ffmpeg-enc b/scripts/xbox360-ffmpeg-enc new file mode 100755 index 0000000..aab754f --- /dev/null +++ b/scripts/xbox360-ffmpeg-enc @@ -0,0 +1,2 @@ +#! /usr/bin/env sh +ffmpeg -i "$1" -c:a aac -strict experimental -ac 2 -c:v libx264 -profile:v high -crf 23 "$2" |