aboutsummaryrefslogtreecommitdiff
path: root/public/.local
diff options
context:
space:
mode:
authorMitsuo Tokumori <mitsuo@tokumori.xyz>2025-12-30 01:17:10 +0900
committerMitsuo Tokumori <mitsuo@tokumori.xyz>2025-12-30 01:17:10 +0900
commit897ffe7b3ba43fee0c4418148a185d1cbb7d6425 (patch)
tree9d5fca789746ebb9b8a99902b7aa66b0f6bde2c5 /public/.local
parentd0a3fa2ddd2843a55cce25d29fe61daf27ef1d38 (diff)
QoL small changes
Diffstat (limited to 'public/.local')
-rwxr-xr-xpublic/.local/bin/dmenu-openbook.sh7
-rwxr-xr-xpublic/.local/bin/dmenu-opentable.sh7
-rwxr-xr-xpublic/.local/bin/dmenu-webshortcuts.sh27
-rwxr-xr-xpublic/.local/bin/laptop-xrandr.sh3
-rwxr-xr-xpublic/.local/bin/myfile-handler.sh9
-rwxr-xr-xpublic/.local/bin/network_control.sh7
-rwxr-xr-xpublic/.local/bin/ocrthis.sh2
-rw-r--r--public/.local/share/dmenu/chars/unicode2
8 files changed, 48 insertions, 16 deletions
diff --git a/public/.local/bin/dmenu-openbook.sh b/public/.local/bin/dmenu-openbook.sh
index 6a257c7..e5766d5 100755
--- a/public/.local/bin/dmenu-openbook.sh
+++ b/public/.local/bin/dmenu-openbook.sh
@@ -1,5 +1,10 @@
#!/bin/bash
# xdg-open a file selected through dmenu
+# TODO: merge dmenu-open* into dmenu-open.sh, call it with 1 argument:
+# `dmenu-open.sh books|spreadsheet`
+# `dmenu-open.sh` with no arguments opens a preliminary dmenu to select
+# the category (base directory) from a list. Each category is defined by
+# a path and white-listed file extensions.
path="$HOME/docs/books"
@@ -13,6 +18,6 @@ cd $path
files=$(find . -type f \( -iname "*.pdf" -o -iname "*.epub" \))
selected=$(echo "$files" | dmenu -i -l 20 -p "Select book:")
if [ -n "$selected" ]; then
- xdg-open "$selected"
+ xdg-open "$selected" &
notify
fi
diff --git a/public/.local/bin/dmenu-opentable.sh b/public/.local/bin/dmenu-opentable.sh
index 69786bb..229efff 100755
--- a/public/.local/bin/dmenu-opentable.sh
+++ b/public/.local/bin/dmenu-opentable.sh
@@ -1,7 +1,14 @@
#!/bin/bash
# xdg-open a file selected through dmenu
+notify() {
+ mimetype=$(xdg-mime query filetype "$DIR/$FILE")
+ defaultprogram=$(xdg-mime query default "$mimetype")
+ notify-send "Opening $FILE ($mimetype) with $defaultprogram"
+}
+
DIR="$HOME/docs/spreadsheet"
FILE=$(ls "$DIR" | dmenu -i -l 10 -p "Select spreadsheet:")
[ -z "$FILE" ] && exit 1
+notify
xdg-open "$DIR/$FILE"
diff --git a/public/.local/bin/dmenu-webshortcuts.sh b/public/.local/bin/dmenu-webshortcuts.sh
index 411525d..1578b5d 100755
--- a/public/.local/bin/dmenu-webshortcuts.sh
+++ b/public/.local/bin/dmenu-webshortcuts.sh
@@ -8,15 +8,15 @@
# TODO: Integrate it to dmenu_run (so that this script doens't require a
# dedicated keybinding)
#
+# Usage:
+# 1. Execute program (e.g., keybinding)
+# 2. Input keyword:search_term and press enter
+# 3. If keyword is correct, browser should open the appropiate page
+#
# Mitsuo
# 2023-11-23
input=$(echo "" | dmenu -p 'wp:Hello World')
-## Set Internal Field Separator, save separated fields as an array in $CMD (-a),
-## don't allow backslashes to escape any characters (-r). Feed $input as stdin.
-#IFS=':' read -ra CMD <<< "$input"
-#keyword=${CMD[0]}
-#search_term=${CMD[1]}
keyword="${input%%:*}"
search_term="${input#*:}"
@@ -36,7 +36,7 @@ case "$keyword" in
# Maps
"ggm") xdg-open "https://www.google.com/maps/search/${search_term// /+}" ;;
"osm") xdg-open "https://www.openstreetmap.org/search?query=$search_term" ;;
-
+
# Reference
"wp") xdg-open "https://en.wikipedia.org/wiki/${search_term// /_}" ;;
"wt") xdg-open "https://en.wiktionary.org/wiki/${search_term// /_}" ;;
@@ -46,6 +46,9 @@ case "$keyword" in
# Computer
"arch") xdg-open "https://wiki.archlinux.org/index.php?search=${search_term// /+}" ;;
+ "debian") xdg-open "https://wiki.debian.org/${search_term// /}" ;;
+ "gentoo") xdg-open "https://wiki.gentoo.org/index.php?search=${search_term// /+}" ;;
+ "apt") xdg-open "https://packages.debian.org/search?lang=en&searchon=names&keywords=${search_term// /-}" ;;
"aur") xdg-open "https://aur.archlinux.org/packages?O=0&K=${search_term// /+}" ;;
"so") xdg-open "https://stackoverflow.com/search?q=${search_term// /+}" ;;
"gh") xdg-open "https://github.com/search?q=${search_term// /+}&type=repositories" ;;
@@ -83,13 +86,17 @@ case "$keyword" in
"jisho") xdg-open "https://jisho.org/search/$search_term" ;;
"rae") xdg-open "https://dle.rae.es/?w=$search_term" ;;
- # Mitsuo
- "pw") xdg-open "http://wiki.localhost/index.php?search=${search_term// /+}" ;;
+ # Games
"factorio") xdg-open "https://wiki.factorio.com/${search_term// /_}" ;;
"dst") xdg-open "https://dontstarve.wiki.gg/wiki/${search_term// /_}" ;;
"mc") xdg-open "https://minecraft.wiki/w/${search_term// /_}" ;;
"terraria") xdg-open "https://terraria.wiki.gg/wiki/${search_term// /_}" ;;
+ "gungeon") xdg-open "https://enterthegungeon.fandom.com/wiki/${search_term// /_}" ;;
- *) exit 1 ;;
-esac
+ # Localhost
+ "pw") xdg-open "http://wiki.localhost/index.php?search=${search_term// /+}" ;;
+ *)
+ notify-send "Bad keyword: $keyword"
+ exit 1 ;;
+esac
diff --git a/public/.local/bin/laptop-xrandr.sh b/public/.local/bin/laptop-xrandr.sh
index 833586c..deee7c9 100755
--- a/public/.local/bin/laptop-xrandr.sh
+++ b/public/.local/bin/laptop-xrandr.sh
@@ -25,7 +25,8 @@ only_hdmi_4k() {
}
only_hdmi_2k() {
- xrandr --output eDP --off --output HDMI-A-0 --mode 1920x1080
+ #xrandr --output eDP --off --output HDMI-A-0 --mode 1920x1080
+ xrandr --output eDP --off --output HDMI-A-0 --auto
}
case $1 in
diff --git a/public/.local/bin/myfile-handler.sh b/public/.local/bin/myfile-handler.sh
index 52496cd..df57a9a 100755
--- a/public/.local/bin/myfile-handler.sh
+++ b/public/.local/bin/myfile-handler.sh
@@ -1,8 +1,15 @@
#!/bin/bash
# A script to handle custom protocol
-url="$1"
+notify() {
+ mimetype=$(xdg-mime query filetype "$file_path")
+ defaultprogram=$(xdg-mime query default "$mimetype")
+ notify-send "Opening $(basename $file_path) ($mimetype) with $defaultprogram"
+}
+
+url="$1"
file_path="${url#myfile://}"
file_path=$(echo "$file_path" | sed 's/%20/ /g')
file_path="${file_path/\~/$HOME}"
+notify
xdg-open "$file_path"
diff --git a/public/.local/bin/network_control.sh b/public/.local/bin/network_control.sh
index 4dc4b38..8fe580f 100755
--- a/public/.local/bin/network_control.sh
+++ b/public/.local/bin/network_control.sh
@@ -35,9 +35,12 @@ toggle_network_quarantine() {
fi
}
-# WIP
toggle_bluetooth() {
- :
+ if bluetoothctl show | grep -q "Powered: yes"; then
+ bluetoothctl power off
+ else
+ bluetoothctl power on
+ fi
}
case $1 in
diff --git a/public/.local/bin/ocrthis.sh b/public/.local/bin/ocrthis.sh
index 3010a6a..0275d01 100755
--- a/public/.local/bin/ocrthis.sh
+++ b/public/.local/bin/ocrthis.sh
@@ -17,4 +17,4 @@ convert "$1" "${b}.pdf"
# TODO: some contrast enhancement step would help. If text has low contrast
# with background (e.g., blue on black, green on black), then OCR fails.
ocrmypdf "${b}.pdf" "${b}.ocr.pdf"
-mv -f "${b}.ocr.pdf" "${b}.pdf"
+#mv -f "${b}.ocr.pdf" "${b}.pdf"
diff --git a/public/.local/share/dmenu/chars/unicode b/public/.local/share/dmenu/chars/unicode
new file mode 100644
index 0000000..c92f975
--- /dev/null
+++ b/public/.local/share/dmenu/chars/unicode
@@ -0,0 +1,2 @@
+# useful unicode characters
+〒 jp post mark 郵便記号