From 897ffe7b3ba43fee0c4418148a185d1cbb7d6425 Mon Sep 17 00:00:00 2001 From: Mitsuo Tokumori Date: Tue, 30 Dec 2025 01:17:10 +0900 Subject: QoL small changes --- public/.local/bin/dmenu-openbook.sh | 7 ++++++- public/.local/bin/dmenu-opentable.sh | 7 +++++++ public/.local/bin/dmenu-webshortcuts.sh | 27 +++++++++++++++++---------- public/.local/bin/laptop-xrandr.sh | 3 ++- public/.local/bin/myfile-handler.sh | 9 ++++++++- public/.local/bin/network_control.sh | 7 +++++-- public/.local/bin/ocrthis.sh | 2 +- 7 files changed, 46 insertions(+), 16 deletions(-) (limited to 'public/.local/bin') 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" -- cgit v1.2.3