summaryrefslogtreecommitdiff
path: root/scripts/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/desktop')
-rwxr-xr-xscripts/desktop/7z-password2
-rwxr-xr-xscripts/desktop/battery6
-rwxr-xr-xscripts/desktop/cpu-vulns2
-rwxr-xr-xscripts/desktop/dbus-sway-environment5
-rwxr-xr-xscripts/desktop/discord-wayland2
-rwxr-xr-xscripts/desktop/dmenu-emoji2
-rwxr-xr-xscripts/desktop/dmenu-path3
-rwxr-xr-xscripts/desktop/dmenu-path03
-rwxr-xr-xscripts/desktop/gpg-pubkey2
-rwxr-xr-xscripts/desktop/img-fstype2
-rwxr-xr-xscripts/desktop/install-as-needed5
-rwxr-xr-xscripts/desktop/looking-glass2
-rwxr-xr-xscripts/desktop/moonrune-charset-utf86
-rwxr-xr-xscripts/desktop/mount-nfs2
-rwxr-xr-xscripts/desktop/rewrite-git8
-rwxr-xr-xscripts/desktop/screenshot48
-rwxr-xr-xscripts/desktop/shift-jis-zip2
-rwxr-xr-xscripts/desktop/sp6
-rwxr-xr-xscripts/desktop/term-font-size20
-rwxr-xr-xscripts/desktop/ts-date2
-rwxr-xr-xscripts/desktop/wlsunset-toggle10
-rwxr-xr-xscripts/desktop/xbox360-ffmpeg-enc2
22 files changed, 142 insertions, 0 deletions
diff --git a/scripts/desktop/7z-password b/scripts/desktop/7z-password
new file mode 100755
index 0000000..72e90f9
--- /dev/null
+++ b/scripts/desktop/7z-password
@@ -0,0 +1,2 @@
+#! /usr/bin/env sh
+7z a -p -mhe=on $1 $2
diff --git a/scripts/desktop/battery b/scripts/desktop/battery
new file mode 100755
index 0000000..c09992a
--- /dev/null
+++ b/scripts/desktop/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/desktop/cpu-vulns b/scripts/desktop/cpu-vulns
new file mode 100755
index 0000000..e55ad9c
--- /dev/null
+++ b/scripts/desktop/cpu-vulns
@@ -0,0 +1,2 @@
+#! /usr/bin/env sh
+tail -n +1 /sys/devices/system/cpu/vulnerabilities/*
diff --git a/scripts/desktop/dbus-sway-environment b/scripts/desktop/dbus-sway-environment
new file mode 100755
index 0000000..249d610
--- /dev/null
+++ b/scripts/desktop/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/desktop/discord-wayland b/scripts/desktop/discord-wayland
new file mode 100755
index 0000000..ec8a106
--- /dev/null
+++ b/scripts/desktop/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/desktop/dmenu-emoji b/scripts/desktop/dmenu-emoji
new file mode 100755
index 0000000..07c1900
--- /dev/null
+++ b/scripts/desktop/dmenu-emoji
@@ -0,0 +1,2 @@
+#! /usr/bin/env sh
+jq -r ".[] | .emoji + \" \" + (.aliases[0])" /etc/emoji.json
diff --git a/scripts/desktop/dmenu-path b/scripts/desktop/dmenu-path
new file mode 100755
index 0000000..9c8122a
--- /dev/null
+++ b/scripts/desktop/dmenu-path
@@ -0,0 +1,3 @@
+#! /usr/bin/env sh
+# https://github.com/ema/dotfiles/blob/fb7f5cab530daba74edefb9cecb401262db063a9/bin/dmenu_path
+printf $PATH -print0 | tr ':' '\0' | uniq -z | xargs -0 ls -Llu --time-style=+%s | awk '/^(-|l)/ { printf $6" "$7"\n" }' | sort -rn | cut -d' ' -f 2
diff --git a/scripts/desktop/dmenu-path0 b/scripts/desktop/dmenu-path0
new file mode 100755
index 0000000..593ecf6
--- /dev/null
+++ b/scripts/desktop/dmenu-path0
@@ -0,0 +1,3 @@
+#! /usr/bin/env sh
+# https://github.com/ema/dotfiles/blob/fb7f5cab530daba74edefb9cecb401262db063a9/bin/dmenu_path
+printf $PATH -print0 | tr ':' '\0' | uniq -z | xargs -0 ls -Llu --time-style=+%s | awk '/^(-|l)/ { printf $6" "$7"\0" }' | sort -zrn | cut -z -d' ' -f 2
diff --git a/scripts/desktop/gpg-pubkey b/scripts/desktop/gpg-pubkey
new file mode 100755
index 0000000..5353972
--- /dev/null
+++ b/scripts/desktop/gpg-pubkey
@@ -0,0 +1,2 @@
+#! /usr/bin/env sh
+gpg --export -a "Andrew Opalach <andrew@akon.city>"
diff --git a/scripts/desktop/img-fstype b/scripts/desktop/img-fstype
new file mode 100755
index 0000000..82df6b8
--- /dev/null
+++ b/scripts/desktop/img-fstype
@@ -0,0 +1,2 @@
+#! /usr/bin/env sh
+blkid -o value -s TYPE $1
diff --git a/scripts/desktop/install-as-needed b/scripts/desktop/install-as-needed
new file mode 100755
index 0000000..9db4ff1
--- /dev/null
+++ b/scripts/desktop/install-as-needed
@@ -0,0 +1,5 @@
+#! /usr/bin/env sh
+export NIXPKGS_ALLOW_UNFREE=1
+PKG=$1
+shift
+nix shell --impure --expr "with (import (builtins.getFlake ''nixpkgs'') {});$PKG" --command "$@"
diff --git a/scripts/desktop/looking-glass b/scripts/desktop/looking-glass
new file mode 100755
index 0000000..5ce9cf4
--- /dev/null
+++ b/scripts/desktop/looking-glass
@@ -0,0 +1,2 @@
+#! /usr/bin/env sh
+looking-glass-client -c 192.168.1.192 -f /dev/shm2/looking-glass win:dontUpscale
diff --git a/scripts/desktop/moonrune-charset-utf8 b/scripts/desktop/moonrune-charset-utf8
new file mode 100755
index 0000000..d3e8343
--- /dev/null
+++ b/scripts/desktop/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/desktop/mount-nfs b/scripts/desktop/mount-nfs
new file mode 100755
index 0000000..a07f4cf
--- /dev/null
+++ b/scripts/desktop/mount-nfs
@@ -0,0 +1,2 @@
+#! /usr/bin/env sh
+sudo mount -t nfs4 -o noatime,nodiratime,rw,hard,fsc,proto=tcp,timeo=600,retrans=2,nfsvers=4,minorversion=2 moyo:$1 $2
diff --git a/scripts/desktop/rewrite-git b/scripts/desktop/rewrite-git
new file mode 100755
index 0000000..b48ba4d
--- /dev/null
+++ b/scripts/desktop/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/desktop/screenshot b/scripts/desktop/screenshot
new file mode 100755
index 0000000..ddeb73a
--- /dev/null
+++ b/scripts/desktop/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/desktop/shift-jis-zip b/scripts/desktop/shift-jis-zip
new file mode 100755
index 0000000..30dab2e
--- /dev/null
+++ b/scripts/desktop/shift-jis-zip
@@ -0,0 +1,2 @@
+#! /usr/bin/env sh
+unzip -O shift-jis "$1"
diff --git a/scripts/desktop/sp b/scripts/desktop/sp
new file mode 100755
index 0000000..19d38a1
--- /dev/null
+++ b/scripts/desktop/sp
@@ -0,0 +1,6 @@
+#! /usr/bin/env sh
+if [ $# -eq 0 ]; then
+ wl-paste | aspell -a
+else
+ echo "$@" | aspell -a
+fi
diff --git a/scripts/desktop/term-font-size b/scripts/desktop/term-font-size
new file mode 100755
index 0000000..0637b12
--- /dev/null
+++ b/scripts/desktop/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/desktop/ts-date b/scripts/desktop/ts-date
new file mode 100755
index 0000000..f16517f
--- /dev/null
+++ b/scripts/desktop/ts-date
@@ -0,0 +1,2 @@
+#! /usr/bin/env sh
+date -d @$1
diff --git a/scripts/desktop/wlsunset-toggle b/scripts/desktop/wlsunset-toggle
new file mode 100755
index 0000000..7dcd06e
--- /dev/null
+++ b/scripts/desktop/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/desktop/xbox360-ffmpeg-enc b/scripts/desktop/xbox360-ffmpeg-enc
new file mode 100755
index 0000000..aab754f
--- /dev/null
+++ b/scripts/desktop/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"