diff options
| author | Mitsuo Tokumori <[email protected]> | 2024-09-11 04:25:38 +0900 |
|---|---|---|
| committer | Mitsuo Tokumori <[email protected]> | 2024-09-11 04:25:38 +0900 |
| commit | 37ff7062874b72bafa99afe661f42653565ed511 (patch) | |
| tree | 60372bf7fdb94c9034c7d1cc5a17cd7df526c4fc /local/bin | |
| parent | dca319b8d9d221f1aaf3a00ee457d202096c66ac (diff) | |
| download | dotfiles-37ff7062874b72bafa99afe661f42653565ed511.tar.gz dotfiles-37ff7062874b72bafa99afe661f42653565ed511.tar.bz2 dotfiles-37ff7062874b72bafa99afe661f42653565ed511.zip | |
RESTRUCTURE. Replicate relative paths in public/
Diffstat (limited to 'local/bin')
| -rw-r--r-- | local/bin/README.txt | 17 | ||||
| -rwxr-xr-x | local/bin/audio_control.sh | 37 | ||||
| -rwxr-xr-x | local/bin/brightness_control.sh | 17 | ||||
| -rwxr-xr-x | local/bin/build-latex.sh | 21 | ||||
| -rwxr-xr-x | local/bin/dmenu-webshortcuts.sh | 93 | ||||
| -rw-r--r-- | local/bin/git-prompt.sh | 589 | ||||
| -rwxr-xr-x | local/bin/input_control.sh | 62 | ||||
| -rwxr-xr-x | local/bin/laptop-backup.sh | 38 | ||||
| -rwxr-xr-x | local/bin/laptop-xinput_setup.sh | 13 | ||||
| -rwxr-xr-x | local/bin/laptop-xrandr.sh | 23 | ||||
| -rwxr-xr-x | local/bin/lp1-unzip_deletebinaries_zip.sh | 20 | ||||
| -rwxr-xr-x | local/bin/myfile-handler.sh | 7 | ||||
| -rwxr-xr-x | local/bin/network_control.sh | 53 | ||||
| -rwxr-xr-x | local/bin/ocrthis.sh | 20 | ||||
| -rwxr-xr-x | local/bin/rename_pictures.sh | 16 | ||||
| -rwxr-xr-x | local/bin/sb-audio | 35 | ||||
| -rwxr-xr-x | local/bin/sb-battery | 37 | ||||
| -rwxr-xr-x | local/bin/sb-input | 9 | ||||
| -rwxr-xr-x | local/bin/sb-network | 52 | ||||
| -rwxr-xr-x | local/bin/scan_loop.sh | 33 | ||||
| -rwxr-xr-x | local/bin/screenshot.sh | 21 | ||||
| -rwxr-xr-x | local/bin/screenshot_ocr.sh | 29 | ||||
| -rwxr-xr-x | local/bin/setbg.sh | 9 | ||||
| -rwxr-xr-x | local/bin/setup_default_apps.sh | 31 | ||||
| -rwxr-xr-x | local/bin/updatewebsite.sh | 9 |
25 files changed, 0 insertions, 1291 deletions
diff --git a/local/bin/README.txt b/local/bin/README.txt deleted file mode 100644 index 280b362..0000000 --- a/local/bin/README.txt +++ /dev/null @@ -1,17 +0,0 @@ -My Linux executable scripts. - -NOTES -* Beware of not leaking personal information - -I also use other people's awesome scrips. I store them in `~/code` and then -slink the ones I use in `~/.local/bin`. - -NOTATION -(notation is messed up, I'd be better if only used dashed prefixes) -* All scripts here should end in ".sh" -* `laptop-*` scripts might only work on my current machine -* `sb-*` scripts are meant to be called by dwmblocks -* `*_control` scripts are used in conjunction with xbindkeys(1) and `sb-*` - See also: - https://github.com/LukeSmithxyz/voidrice/tree/master/.local/bin/statusbar - https://github.com/LukeSmithxyz/dwmblocks/blob/master/config.h diff --git a/local/bin/audio_control.sh b/local/bin/audio_control.sh deleted file mode 100755 index a257120..0000000 --- a/local/bin/audio_control.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -delta=${2:-10} -signal=10 - -# signal dwmblocks to update volume block -send_signal() { - pkill -RTMIN+$signal dwmblocks -} - -# WIP: change default sink (speaker). E.g., when connecting HDMI. -change_sink() { - pactl list sinks | grep "Name:" - # Use tab completion if set up interactively - pactl "set-default-sink alsa_output.pci-0000_05_00.6.analog-stereo" -} - -case $1 in - inc) pactl set-sink-volume @DEFAULT_SINK@ +$delta% ;; - dec) pactl set-sink-volume @DEFAULT_SINK@ -$delta% ;; - micinc) pactl set-source-volume @DEFAULT_SOURCE@ +$delta% ;; - micdec) pactl set-source-volume @DEFAULT_SOURCE@ -$delta% ;; - mutetoggle) pactl set-sink-mute @DEFAULT_SINK@ toggle ;; - deafentoggle) pactl set-source-mute @DEFAULT_SOURCE@ toggle ;; - *) - echo Speaker: - pactl get-sink-volume @DEFAULT_SINK@ - pactl get-sink-mute @DEFAULT_SINK@ - echo -e "\nMic:" - pactl get-source-volume @DEFAULT_SOURCE@ - pactl get-source-mute @DEFAULT_SOURCE@ - echo -e "\nApplications:" - pactl list sink-inputs | grep -e 'Sink Input' -e 'application.name' -e 'Volume:' - ;; -esac - -send_signal diff --git a/local/bin/brightness_control.sh b/local/bin/brightness_control.sh deleted file mode 100755 index 13345d7..0000000 --- a/local/bin/brightness_control.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -delta=${2:-10} -signal=11 - -# signal dwmblocks to update block -send_signal() { - pkill -RTMIN+$signal dwmblocks -} - -case $1 in - inc) xbacklight -inc $delta ;; - dec) xbacklight -dec $delta ;; - *) xbacklight -get ;; -esac - -send_signal diff --git a/local/bin/build-latex.sh b/local/bin/build-latex.sh deleted file mode 100755 index 7048246..0000000 --- a/local/bin/build-latex.sh +++ /dev/null @@ -1,21 +0,0 @@ -# Build single latex file using xelatex - -if [ $# -ne 1 ]; then - echo "Usage: $(basename "$0") FILE" - exit 1 -fi - -cleanup() { - # cleanup of auxiliary files - rm -f *.aux *.fls *.fdb_latexmk - # rm *.log -} - -xelatex $1 || exit # Initial compilation -#bibtex # Bibliography tool -#xelatex $1 || exit # Incorporate bibliography changes -xelatex $1 || exit # Fix cross-references -#xelatex $1 || exit # 4th run just to be safe -cleanup -echo "## Mispelled words:" -pdftotext "${1%.tex}.pdf" - | hunspell -d en_US -i utf-8 -a | sort | uniq diff --git a/local/bin/dmenu-webshortcuts.sh b/local/bin/dmenu-webshortcuts.sh deleted file mode 100755 index e1d233c..0000000 --- a/local/bin/dmenu-webshortcuts.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash - -# Use dmenu and user-defined web shorcuts to query websites faster. -# -# This script tries to mimic Krunner Web Search Keywords functionality. -# See: https://userbase.kde.org/Plasma/Krunner#Browse_websites -# -# TODO: Integrate it to dmenu_run (so that this script doens't require a -# dedicated keybinding) -# -# 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#*:}" - -# Define web shortcuts here -case "$keyword" in - # Search - "dd") xdg-open "https://duckduckgo.com/?t=h_&q=${search_term// /+}" ;; - "gg") xdg-open "https://www.google.com/search?q=$search_term" ;; - "bing") xdg-open "https://www.bing.com/search?q=${search_term// /+}" ;; - "metac") xdg-open "https://www.metacrawler.com/serp?q=${search_term// /+}" ;; - - # Finance - "ggf") xdg-open "https://www.google.com/finance/quote/$search_term?window=1Y" ;; - "yf") xdg-open "https://finance.yahoo.com/quote/$search_term" ;; - "bb") xdg-open "https://www.bloomberg.com/quote/$search_term" ;; - - # 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// /_}" ;; - "wv") xdg-open "https://en.wikivoyage.org/wiki/${search_term// /_}" ;; - "scholar") xdg-open "https://scholar.google.com/scholar?hl=en&q=${search_query// /+}" ;; - "arxiv") xdg-open "https://arxiv.org/search/?query=${search_query// /+}" ;; - - # Computer - "arch") xdg-open "https://wiki.archlinux.org/index.php?search=${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" ;; - "gl") xdg-open "https://about.gitlab.com/search?searchText=$search_term" ;; - "pypi") xdg-open "https://pypi.org/search/?q=${search_term// /+}&o=" ;; - "npm") xdg-open "https://www.npmjs.com/search?q=${search_term// /+}" ;; - - # Media - "yt") xdg-open "https://www.youtube.com/results?search_query=$search_term" ;; - "vm") xdg-open "https://vimeo.com/search?q=$search_term" ;; - "sp") xdg-open "https://open.spotify.com/search/$search_term" ;; - "sc") xdg-open "https://soundcloud.com/search?q=$search_term" ;; - "dz") xdg-open "https://www.deezer.com/search/$search_term" ;; - "imdb") xdg-open "https://www.imdb.com/find/?q=$search_term" ;; - - # Social Media - "x") xdg-open "https://x.com/search?q=$search_term&src=typed_query" ;; - "rd") xdg-open "https://duckduckgo.com/?t=h_&q=site%3Areddit.com+${search_term// /+}&ia=web" ;; - "ig") xdg-open "https://duckduckgo.com/?q=site%3Ainstagram.com+${search_term// /+}&ia=web" ;; - "fb") xdg-open "https://duckduckgo.com/?q=site%3Afacebook.com+${search_term// /+}&ia=web" ;; - - # Shopping - "amzn") xdg-open "https://www.amazon.com/s?k=${search_term// /+}" ;; - "amznjp") xdg-open "https://www.amazon.co.jp/s?k=${search_term// /+}" ;; - "ebay") xdg-open "https://www.ebay.com/sch/i.html?_nkw=${search_term// /+}" ;; - - # Utilities - "ggt") xdg-open "https://translate.google.com/?sl=auto&tl=en&text=$search_term&op=translate" ;; - "en2es") xdg-open "https://www.wordreference.com/es/translation.asp?tranword=$search_term" ;; - "es2en") xdg-open "https://www.wordreference.com/es/en/translation.asp?spen=$search_term" ;; - "en2de") xdg-open "https://www.wordreference.com/es/en/translation.asp?spen=$search_term" ;; - "de2en") xdg-open "https://www.wordreference.com/deen/$search_term" ;; - "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.pulse15/index.php?search=${search_term// /+}" ;; - "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// /_}" ;; - - *) exit 1 ;; -esac - diff --git a/local/bin/git-prompt.sh b/local/bin/git-prompt.sh deleted file mode 100644 index 1435548..0000000 --- a/local/bin/git-prompt.sh +++ /dev/null @@ -1,589 +0,0 @@ -# bash/zsh git prompt support -# -# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> -# Distributed under the GNU General Public License, version 2.0. -# -# This script allows you to see repository status in your prompt. -# -# To enable: -# -# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh). -# 2) Add the following line to your .bashrc/.zshrc: -# source ~/.git-prompt.sh -# 3a) Change your PS1 to call __git_ps1 as -# command-substitution: -# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' -# ZSH: setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ ' -# the optional argument will be used as format string. -# 3b) Alternatively, for a slightly faster prompt, __git_ps1 can -# be used for PROMPT_COMMAND in Bash or for precmd() in Zsh -# with two parameters, <pre> and <post>, which are strings -# you would put in $PS1 before and after the status string -# generated by the git-prompt machinery. e.g. -# Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "' -# will show username, at-sign, host, colon, cwd, then -# various status string, followed by dollar and SP, as -# your prompt. -# ZSH: precmd () { __git_ps1 "%n" ":%~$ " "|%s" } -# will show username, pipe, then various status string, -# followed by colon, cwd, dollar and SP, as your prompt. -# Optionally, you can supply a third argument with a printf -# format string to finetune the output of the branch status -# -# The repository status will be displayed only if you are currently in a -# git repository. The %s token is the placeholder for the shown status. -# -# The prompt status always includes the current branch name. -# -# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value, -# unstaged (*) and staged (+) changes will be shown next to the branch -# name. You can configure this per-repository with the -# bash.showDirtyState variable, which defaults to true once -# GIT_PS1_SHOWDIRTYSTATE is enabled. -# -# You can also see if currently something is stashed, by setting -# GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed, -# then a '$' will be shown next to the branch name. -# -# If you would like to see if there're untracked files, then you can set -# GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked -# files, then a '%' will be shown next to the branch name. You can -# configure this per-repository with the bash.showUntrackedFiles -# variable, which defaults to true once GIT_PS1_SHOWUNTRACKEDFILES is -# enabled. -# -# If you would like to see the difference between HEAD and its upstream, -# set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">" -# indicates you are ahead, "<>" indicates you have diverged and "=" -# indicates that there is no difference. You can further control -# behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list -# of values: -# -# verbose show number of commits ahead/behind (+/-) upstream -# name if verbose, then also show the upstream abbrev name -# legacy don't use the '--count' option available in recent -# versions of git-rev-list -# git always compare HEAD to @{upstream} -# svn always compare HEAD to your SVN upstream -# -# By default, __git_ps1 will compare HEAD to your SVN upstream if it can -# find one, or @{upstream} otherwise. Once you have set -# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by -# setting the bash.showUpstream config variable. -# -# You can change the separator between the branch name and the above -# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator -# is SP. -# -# When there is an in-progress operation such as a merge, rebase, -# revert, cherry-pick, or bisect, the prompt will include information -# related to the operation, often in the form "|<OPERATION-NAME>". -# -# When the repository has a sparse-checkout, a notification of the form -# "|SPARSE" will be included in the prompt. This can be shortened to a -# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted -# by setting GIT_PS1_OMITSPARSESTATE. -# -# If you would like to see more information about the identity of -# commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE -# to one of these values: -# -# contains relative to newer annotated tag (v1.6.3.2~35) -# branch relative to newer tag or branch (master~4) -# describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f) -# tag relative to any older tag (v1.6.3.1-13-gdd42c2f) -# default exactly matching tag -# -# If you would like a colored hint about the current dirty state, set -# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on -# the colored output of "git status -sb" and are available only when -# using __git_ps1 for PROMPT_COMMAND or precmd in Bash, -# but always available in Zsh. -# -# If you would like __git_ps1 to do nothing in the case when the current -# directory is set up to be ignored by git, then set -# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the -# repository level by setting bash.hideIfPwdIgnored to "false". - -# check whether printf supports -v -__git_printf_supports_v= -printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1 - -# stores the divergence from upstream in $p -# used by GIT_PS1_SHOWUPSTREAM -__git_ps1_show_upstream () -{ - local key value - local svn_remote svn_url_pattern count n - local upstream_type=git legacy="" verbose="" name="" - - svn_remote=() - # get some config options from git-config - local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')" - while read -r key value; do - case "$key" in - bash.showupstream) - GIT_PS1_SHOWUPSTREAM="$value" - if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then - p="" - return - fi - ;; - svn-remote.*.url) - svn_remote[$((${#svn_remote[@]} + 1))]="$value" - svn_url_pattern="$svn_url_pattern\\|$value" - upstream_type=svn+git # default upstream type is SVN if available, else git - ;; - esac - done <<< "$output" - - # parse configuration values - local option - for option in ${GIT_PS1_SHOWUPSTREAM}; do - case "$option" in - git|svn) upstream_type="$option" ;; - verbose) verbose=1 ;; - legacy) legacy=1 ;; - name) name=1 ;; - esac - done - - # Find our upstream type - case "$upstream_type" in - git) upstream_type="@{upstream}" ;; - svn*) - # get the upstream from the "git-svn-id: ..." in a commit message - # (git-svn uses essentially the same procedure internally) - local -a svn_upstream - svn_upstream=($(git log --first-parent -1 \ - --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) - if [[ 0 -ne ${#svn_upstream[@]} ]]; then - svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]} - svn_upstream=${svn_upstream%@*} - local n_stop="${#svn_remote[@]}" - for ((n=1; n <= n_stop; n++)); do - svn_upstream=${svn_upstream#${svn_remote[$n]}} - done - - if [[ -z "$svn_upstream" ]]; then - # default branch name for checkouts with no layout: - upstream_type=${GIT_SVN_ID:-git-svn} - else - upstream_type=${svn_upstream#/} - fi - elif [[ "svn+git" = "$upstream_type" ]]; then - upstream_type="@{upstream}" - fi - ;; - esac - - # Find how many commits we are ahead/behind our upstream - if [[ -z "$legacy" ]]; then - count="$(git rev-list --count --left-right \ - "$upstream_type"...HEAD 2>/dev/null)" - else - # produce equivalent output to --count for older versions of git - local commits - if commits="$(git rev-list --left-right "$upstream_type"...HEAD 2>/dev/null)" - then - local commit behind=0 ahead=0 - for commit in $commits - do - case "$commit" in - "<"*) ((behind++)) ;; - *) ((ahead++)) ;; - esac - done - count="$behind $ahead" - else - count="" - fi - fi - - # calculate the result - if [[ -z "$verbose" ]]; then - case "$count" in - "") # no upstream - p="" ;; - "0 0") # equal to upstream - p="=" ;; - "0 "*) # ahead of upstream - p=">" ;; - *" 0") # behind upstream - p="<" ;; - *) # diverged from upstream - p="<>" ;; - esac - else # verbose, set upstream instead of p - case "$count" in - "") # no upstream - upstream="" ;; - "0 0") # equal to upstream - upstream="|u=" ;; - "0 "*) # ahead of upstream - upstream="|u+${count#0 }" ;; - *" 0") # behind upstream - upstream="|u-${count% 0}" ;; - *) # diverged from upstream - upstream="|u+${count#* }-${count% *}" ;; - esac - if [[ -n "$count" && -n "$name" ]]; then - __git_ps1_upstream_name=$(git rev-parse \ - --abbrev-ref "$upstream_type" 2>/dev/null) - if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then - upstream="$upstream \${__git_ps1_upstream_name}" - else - upstream="$upstream ${__git_ps1_upstream_name}" - # not needed anymore; keep user's - # environment clean - unset __git_ps1_upstream_name - fi - fi - fi - -} - -# Helper function that is meant to be called from __git_ps1. It -# injects color codes into the appropriate gitstring variables used -# to build a gitstring. Colored variables are responsible for clearing -# their own color. -__git_ps1_colorize_gitstring () -{ - if [[ -n ${ZSH_VERSION-} ]]; then - local c_red='%F{red}' - local c_green='%F{green}' - local c_lblue='%F{blue}' - local c_clear='%f' - else - # Using \[ and \] around colors is necessary to prevent - # issues with command line editing/browsing/completion! - local c_red='\[\e[31m\]' - local c_green='\[\e[32m\]' - local c_lblue='\[\e[1;34m\]' - local c_clear='\[\e[0m\]' - fi - local bad_color=$c_red - local ok_color=$c_green - local flags_color="$c_lblue" - - local branch_color="" - if [ $detached = no ]; then - branch_color="$ok_color" - else - branch_color="$bad_color" - fi - if [ -n "$c" ]; then - c="$branch_color$c$c_clear" - fi - b="$branch_color$b$c_clear" - - if [ -n "$w" ]; then - w="$bad_color$w$c_clear" - fi - if [ -n "$i" ]; then - i="$ok_color$i$c_clear" - fi - if [ -n "$s" ]; then - s="$flags_color$s$c_clear" - fi - if [ -n "$u" ]; then - u="$bad_color$u$c_clear" - fi -} - -# Helper function to read the first line of a file into a variable. -# __git_eread requires 2 arguments, the file path and the name of the -# variable, in that order. -__git_eread () -{ - test -r "$1" && IFS=$'\r\n' read "$2" <"$1" -} - -# see if a cherry-pick or revert is in progress, if the user has committed a -# conflict resolution with 'git commit' in the middle of a sequence of picks or -# reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read -# the todo file. -__git_sequencer_status () -{ - local todo - if test -f "$g/CHERRY_PICK_HEAD" - then - r="|CHERRY-PICKING" - return 0; - elif test -f "$g/REVERT_HEAD" - then - r="|REVERTING" - return 0; - elif __git_eread "$g/sequencer/todo" todo - then - case "$todo" in - p[\ \ ]|pick[\ \ ]*) - r="|CHERRY-PICKING" - return 0 - ;; - revert[\ \ ]*) - r="|REVERTING" - return 0 - ;; - esac - fi - return 1 -} - -# __git_ps1 accepts 0 or 1 arguments (i.e., format string) -# when called from PS1 using command substitution -# in this mode it prints text to add to bash PS1 prompt (includes branch name) -# -# __git_ps1 requires 2 or 3 arguments when called from PROMPT_COMMAND (pc) -# in that case it _sets_ PS1. The arguments are parts of a PS1 string. -# when two arguments are given, the first is prepended and the second appended -# to the state string when assigned to PS1. -# The optional third parameter will be used as printf format string to further -# customize the output of the git-status string. -# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true -__git_ps1 () -{ - # preserve exit status - local exit=$? - local pcmode=no - local detached=no - local ps1pc_start='\u@\h:\w ' - local ps1pc_end='\$ ' - local printf_format=' (%s)' - - case "$#" in - 2|3) pcmode=yes - ps1pc_start="$1" - ps1pc_end="$2" - printf_format="${3:-$printf_format}" - # set PS1 to a plain prompt so that we can - # simply return early if the prompt should not - # be decorated - PS1="$ps1pc_start$ps1pc_end" - ;; - 0|1) printf_format="${1:-$printf_format}" - ;; - *) return $exit - ;; - esac - - # ps1_expanded: This variable is set to 'yes' if the shell - # subjects the value of PS1 to parameter expansion: - # - # * bash does unless the promptvars option is disabled - # * zsh does not unless the PROMPT_SUBST option is set - # * POSIX shells always do - # - # If the shell would expand the contents of PS1 when drawing - # the prompt, a raw ref name must not be included in PS1. - # This protects the user from arbitrary code execution via - # specially crafted ref names. For example, a ref named - # 'refs/heads/$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' might cause the - # shell to execute 'sudo rm -rf /' when the prompt is drawn. - # - # Instead, the ref name should be placed in a separate global - # variable (in the __git_ps1_* namespace to avoid colliding - # with the user's environment) and that variable should be - # referenced from PS1. For example: - # - # __git_ps1_foo=$(do_something_to_get_ref_name) - # PS1="...stuff...\${__git_ps1_foo}...stuff..." - # - # If the shell does not expand the contents of PS1, the raw - # ref name must be included in PS1. - # - # The value of this variable is only relevant when in pcmode. - # - # Assume that the shell follows the POSIX specification and - # expands PS1 unless determined otherwise. (This is more - # likely to be correct if the user has a non-bash, non-zsh - # shell and safer than the alternative if the assumption is - # incorrect.) - # - local ps1_expanded=yes - [ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no - [ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no - - local repo_info rev_parse_exit_code - repo_info="$(git rev-parse --git-dir --is-inside-git-dir \ - --is-bare-repository --is-inside-work-tree \ - --short HEAD 2>/dev/null)" - rev_parse_exit_code="$?" - - if [ -z "$repo_info" ]; then - return $exit - fi - - local short_sha="" - if [ "$rev_parse_exit_code" = "0" ]; then - short_sha="${repo_info##*$'\n'}" - repo_info="${repo_info%$'\n'*}" - fi - local inside_worktree="${repo_info##*$'\n'}" - repo_info="${repo_info%$'\n'*}" - local bare_repo="${repo_info##*$'\n'}" - repo_info="${repo_info%$'\n'*}" - local inside_gitdir="${repo_info##*$'\n'}" - local g="${repo_info%$'\n'*}" - - if [ "true" = "$inside_worktree" ] && - [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] && - [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] && - git check-ignore -q . - then - return $exit - fi - - local sparse="" - if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] && - [ -z "${GIT_PS1_OMITSPARSESTATE-}" ] && - [ "$(git config --bool core.sparseCheckout)" = "true" ]; then - sparse="|SPARSE" - fi - - local r="" - local b="" - local step="" - local total="" - if [ -d "$g/rebase-merge" ]; then - __git_eread "$g/rebase-merge/head-name" b - __git_eread "$g/rebase-merge/msgnum" step - __git_eread "$g/rebase-merge/end" total - r="|REBASE" - else - if [ -d "$g/rebase-apply" ]; then - __git_eread "$g/rebase-apply/next" step - __git_eread "$g/rebase-apply/last" total - if [ -f "$g/rebase-apply/rebasing" ]; then - __git_eread "$g/rebase-apply/head-name" b - r="|REBASE" - elif [ -f "$g/rebase-apply/applying" ]; then - r="|AM" - else - r="|AM/REBASE" - fi - elif [ -f "$g/MERGE_HEAD" ]; then - r="|MERGING" - elif __git_sequencer_status; then - : - elif [ -f "$g/BISECT_LOG" ]; then - r="|BISECTING" - fi - - if [ -n "$b" ]; then - : - elif [ -h "$g/HEAD" ]; then - # symlink symbolic ref - b="$(git symbolic-ref HEAD 2>/dev/null)" - else - local head="" - if ! __git_eread "$g/HEAD" head; then - return $exit - fi - # is it a symbolic ref? - b="${head#ref: }" - if [ "$head" = "$b" ]; then - detached=yes - b="$( - case "${GIT_PS1_DESCRIBE_STYLE-}" in - (contains) - git describe --contains HEAD ;; - (branch) - git describe --contains --all HEAD ;; - (tag) - git describe --tags HEAD ;; - (describe) - git describe HEAD ;; - (* | default) - git describe --tags --exact-match HEAD ;; - esac 2>/dev/null)" || - - b="$short_sha..." - b="($b)" - fi - fi - fi - - if [ -n "$step" ] && [ -n "$total" ]; then - r="$r $step/$total" - fi - - local w="" - local i="" - local s="" - local u="" - local h="" - local c="" - local p="" # short version of upstream state indicator - local upstream="" # verbose version of upstream state indicator - - if [ "true" = "$inside_gitdir" ]; then - if [ "true" = "$bare_repo" ]; then - c="BARE:" - else - b="GIT_DIR!" - fi - elif [ "true" = "$inside_worktree" ]; then - if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] && - [ "$(git config --bool bash.showDirtyState)" != "false" ] - then - git diff --no-ext-diff --quiet || w="*" - git diff --no-ext-diff --cached --quiet || i="+" - if [ -z "$short_sha" ] && [ -z "$i" ]; then - i="#" - fi - fi - if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] && - git rev-parse --verify --quiet refs/stash >/dev/null - then - s="$" - fi - - if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] && - [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] && - git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null - then - u="%${ZSH_VERSION+%}" - fi - - if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] && - [ "$(git config --bool core.sparseCheckout)" = "true" ]; then - h="?" - fi - - if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then - __git_ps1_show_upstream - fi - fi - - local z="${GIT_PS1_STATESEPARATOR-" "}" - - b=${b##refs/heads/} - if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then - __git_ps1_branch_name=$b - b="\${__git_ps1_branch_name}" - fi - - # NO color option unless in PROMPT_COMMAND mode or it's Zsh - if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then - if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then - __git_ps1_colorize_gitstring - fi - fi - - local f="$h$w$i$s$u$p" - local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}" - - if [ $pcmode = yes ]; then - if [ "${__git_printf_supports_v-}" != yes ]; then - gitstring=$(printf -- "$printf_format" "$gitstring") - else - printf -v gitstring -- "$printf_format" "$gitstring" - fi - PS1="$ps1pc_start$gitstring$ps1pc_end" - else - printf -- "$printf_format" "$gitstring" - fi - - return $exit -} diff --git a/local/bin/input_control.sh b/local/bin/input_control.sh deleted file mode 100755 index f63de3b..0000000 --- a/local/bin/input_control.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# Use either X keyboard extension layouts (setxkbmap), or fcitx (or both). -# -# At first I configured this to use setxkbmap, it works fine. -# -# fcitx already provides keybindings, but I wanted to display -# the current input method in dwmblocks immediatly. So I'm -# adding such support through fcitx5-remote. - -signal=20 - -# signal dwmblocks to update block -send_signal() { - pkill -RTMIN+$signal dwmblocks -} - -# Cycle X keyboard extension layouts -cycle_layouts() { - layouts=(us latam) # X keyboard extension - STATE_FILE="$XDG_STATE_HOME/keyboard_layout_state" - - if [ -f "$STATE_FILE" ]; then - index=$(cat "$STATE_FILE") - else - index=0 - fi - next_index=$(( (index + 1) % ${#layouts[@]} )) - echo $next_index > "$STATE_FILE" - - setxkbmap ${layouts[$index]} -} - -fcitx_control() { - # For this to correctly reflect the state of the system "Share Input State" - # should be set to "All" in fcitx5-configtool. - - case $1 in - en) - fcitx5-remote -c # Closed - fcitx5-remote -g Default - ;; - es) - fcitx5-remote -c # Closed - fcitx5-remote -g Spanish - ;; - ja) - fcitx5-remote -g Default - fcitx5-remote -o # Open - ;; - *) - fcitx5-remote -q # - fcitx5-remote -n - fcitx5-remote - ;; - esac -} - -#cycle_layouts -fcitx_control $1 - -send_signal diff --git a/local/bin/laptop-backup.sh b/local/bin/laptop-backup.sh deleted file mode 100755 index a22c179..0000000 --- a/local/bin/laptop-backup.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# Fast backup using rsync - -if [ $# -ne 2 ]; then - echo "Usage: $(basename "$0") /dev/sdX backup" - exit 1 -fi - -if [ "$(id -u)" -ne 0 ]; then - echo "This script must be run as root." - exit 1 -fi - -rsync_options="-auvP --delete" -device=$1 -name=$2 - -# Note: `name` (nor `device`) should not contain spaces - -cryptsetup open --type luks $device $name -if [ $? -ne 0 ]; then - # bad device - exit 1 -fi -mount /dev/mapper/$name /mnt/$name -# TODO: stop backing up /var. Backup is just for Postgres and Mediawiki. -# `/var` is used by too many applications. Specialy pacman that clutters it -# with cached binaries. -rsync $rsync_options /var /mnt/$name # <10G -rsync $rsync_options /home /mnt/$name # <900G -rsync $rsync_options /etc /mnt/$name # <20M -echo "Backup complete." -df -h #| grep -E "${name}|var|home|etc" -umount /mnt/$name -cryptsetup close $name - -echo "All done. Check \`$ lsblk\` before unplugging the storage device." diff --git a/local/bin/laptop-xinput_setup.sh b/local/bin/laptop-xinput_setup.sh deleted file mode 100755 index e471869..0000000 --- a/local/bin/laptop-xinput_setup.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# See https://wiki.archlinux.org/title/Libinput - -#xinput list -#xinput list-props - -pulse15() { - xinput set-prop "UNIW0001:00 093A:0255 Touchpad" "libinput Tapping Enabled" 1 - #xinput set-prop "UNIW0001:00 093A:0255 Touchpad" "libinput Tapping Enabled Default" 1 -} - -pulse15 diff --git a/local/bin/laptop-xrandr.sh b/local/bin/laptop-xrandr.sh deleted file mode 100755 index cbe9479..0000000 --- a/local/bin/laptop-xrandr.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# See https://wiki.archlinux.org/title/Multihead - -# Didn't know how to get the screen name, this works for now -#screen=$(xrandr | grep "primary" | awk '{ print $1 }') -# But now how do I get the rest? And the correct order? Maybe it's better just -# to define "hardcoded" functions and just call them. - -simple_2_monitor() { - # enable - xrandr --output eDP --auto \ - --output HDMI-A-0 --auto --left-of eDP - # disable - xrandr --output eDP --auto \ - --output HDMI-A-0 --off -} - -# Thank you: https://www.maketecheasier.com/how-to-setup-dual-monitors-with-xrandr/ -# xrandr --auto --output HDMI-A-0 --mode 1920x1080 --right-of eDP - -#simple_2_monitor -xrandr --auto --output HDMI-A-0 --mode 1920x1080 --right-of eDP diff --git a/local/bin/lp1-unzip_deletebinaries_zip.sh b/local/bin/lp1-unzip_deletebinaries_zip.sh deleted file mode 100755 index 3fa4afb..0000000 --- a/local/bin/lp1-unzip_deletebinaries_zip.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# Script for LP1 labs that are uploaded to Google Drive with binaries and -# that causes problems with Google Drive's automatic virus scan. - -# unzip -for f in *.zip; do unzip -q "$f"; done - -# delete build/ and dist/ directories (virus detection in Google Drive) -find . -type d -regex '^.*/\(dist\|build\)$' -print0 | xargs -0 rm -r - -# zip -rm *.zip # remove old zip files -for d in */; do - dirname="${d%/}" - zip -qr "$dirname.zip" "$d" -done - -# dos2unix (for me) -find . -type f -iregex ".*\.\(csv\|cpp\|h\|hpp\)" -print0 | xargs -0 dos2unix diff --git a/local/bin/myfile-handler.sh b/local/bin/myfile-handler.sh deleted file mode 100755 index 40360b8..0000000 --- a/local/bin/myfile-handler.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# A script to handle custom protocol -url="$1" - -file_path="${url#myfile://}" -file_path="${file_path/\~/$HOME}" -xdg-open "$file_path" diff --git a/local/bin/network_control.sh b/local/bin/network_control.sh deleted file mode 100755 index 4dc4b38..0000000 --- a/local/bin/network_control.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -signal=30 - -# signal dwmblocks to update network block -send_signal() { - pkill -RTMIN+$signal dwmblocks -} - -toggle_wifi() { - status=$(nmcli radio wifi) - - if [ "$status" = "enabled" ]; then - nmcli radio wifi off - else - nmcli radio wifi on - fi -} - -# This one is hard because it requires root, and the VPN interface name -# 2 ways to toggle, using systemctl, or wg-quick(1) -# This one might be better controled through a `dmenu` script. -toggle_vpn() { - : -} - -toggle_network_quarantine() { - # Check the status of all wireless devices - if rfkill list | grep -q "Soft blocked: no"; then - # not all blocked - rfkill block all - else - # all blocked - rfkill unblock all - fi -} - -# WIP -toggle_bluetooth() { - : -} - -case $1 in - wifitoggle) toggle_wifi ;; - vpntoggle) toggle_vpn ;; - bluetoothtoggle) toggle_bluetooth ;; - isolatetoggle) toggle_network_quarantine ;; - *) - echo "invalid option :)" - ;; -esac - -send_signal diff --git a/local/bin/ocrthis.sh b/local/bin/ocrthis.sh deleted file mode 100755 index 3010a6a..0000000 --- a/local/bin/ocrthis.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# Creates and OCR PDF out of an image -# (OCR limited to printed characters (handwriting or photograph OCR is bad, if -# any) -# -# Alternatively use `tesseract FILE text` - -if [ $# -ne 1 ]; then - echo "Usage: $(basename "$0") input_file" - # (there is `basename` and `dirname`) - exit 1 -fi - -b="$(basename "$1")" -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" diff --git a/local/bin/rename_pictures.sh b/local/bin/rename_pictures.sh deleted file mode 100755 index a3f2463..0000000 --- a/local/bin/rename_pictures.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Very specific script to bulk rename pictures with some format -# (complex script for a simple task) - -exit # just in case - -shopt -s nullglob -for file in ss_*.png; do - date_part="${file:3:8}" - time_part="${file:12:6}" - new_name="ss-${date_part}T${time_part}0500.png" - - mv "$file" "$new_name" -done -shopt -u nullglob diff --git a/local/bin/sb-audio b/local/bin/sb-audio deleted file mode 100755 index 87ce7d7..0000000 --- a/local/bin/sb-audio +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -# Prints the current volume and 🔇 if muted. - -case $BLOCK_BUTTON in - 1) setsid -w -f "$TERMINAL" -e pulsemixer; pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;; - 2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;; - 4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;; - 5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;; - 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. -- Middle click to mute. -- Scroll to change." ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -#vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)" - -vol="$(pactl get-sink-volume @DEFAULT_SINK@ | awk '/Volume/ { gsub(/%/,"",$5); print $5 }')" -micvol="$(pactl get-source-volume @DEFAULT_SOURCE@ | awk '/Volume/ { gsub(/%/,"",$5); print $5 }')" - -case 1 in - $((vol >= 70)) ) icon="🔊" ;; - $((vol >= 30)) ) icon="🔉" ;; - * ) icon="🔈" ;; -esac - -if pactl get-sink-mute @DEFAULT_SINK@ | grep -q yes; then - icon="🔇" -fi - -if pactl get-source-mute @DEFAULT_SOURCE@ | grep -q no; then - icon="🎤$micvol%"$icon -fi - -echo "$icon$vol%" diff --git a/local/bin/sb-battery b/local/bin/sb-battery deleted file mode 100755 index 93cbe08..0000000 --- a/local/bin/sb-battery +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -# Prints all batteries, their percentage remaining and an emoji corresponding -# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.). - -case $BLOCK_BUTTON in - 3) notify-send "🔋 Battery module" "🔋: discharging -🛑: not charging -♻: stagnant charge -🔌: charging -⚡: charged -❗: battery very low! -- Scroll to change adjust xbacklight." ;; - 4) xbacklight -inc 10 ;; - 5) xbacklight -dec 10 ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -# Loop through all attached batteries and format the info -for battery in /sys/class/power_supply/BAT?*; do - # If non-first battery, print a space separator. - [ -n "${capacity+x}" ] && printf " " - # Sets up the status and capacity - case "$(cat "$battery/status" 2>&1)" in - "Full") status="⚡" ;; - "Discharging") status="🔋" ;; - "Charging") status="🔌" ;; - "Not charging") status="🛑" ;; - "Unknown") status="♻️" ;; - *) exit 1 ;; - esac - capacity="$(cat "$battery/capacity" 2>&1)" - # Will make a warn variable if discharging and low - [ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗" - # Prints the info - printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn -done && printf "\\n" diff --git a/local/bin/sb-input b/local/bin/sb-input deleted file mode 100755 index 4fb1575..0000000 --- a/local/bin/sb-input +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -icon="🌐" -layout="$(setxkbmap -query | grep layout | awk '{print $2}')" - -# fcitx state, 0 for close, 1 for inactive, 2 for active -test $(fcitx5-remote) = 2 && layout="日本語" - -echo $icon$layout diff --git a/local/bin/sb-network b/local/bin/sb-network deleted file mode 100755 index 0bdbe82..0000000 --- a/local/bin/sb-network +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -# Prints some network connectivity status in emoji - -case $BLOCK_BUTTON in - 1) setsid -w -f "$TERMINAL" -e pulsemixer; pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;; - 2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;; - 4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;; - 5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;; - 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted. -- Middle click to mute. -- Scroll to change." ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - - -set_wlan() { - nmcli_status=$(nmcli -t -f TYPE,STATE connection show --active) - wifi=$(echo $nmcli_status | grep -q "802-11-wireless:activated" && echo "📶") - vpn=$(echo $nmcli_status | grep -q "wireguard:activated" && echo "🔒") - wlan="$wifi$vpn" -} - - -set_bt() { - # If bluetooth is on, show number of connected devices and their initials - if ! bluetoothctl show | grep -q "Powered: yes"; then return; fi - ds=$(bluetoothctl devices Connected | cut -d ' ' -f 3-) - if [ -z "$ds" ]; then - bt=$(echo "🦷") - return - fi - N=$(echo "$ds" | wc -l) - ds=$(echo "$ds" | cut -c 1-3 | paste -sd ",") - bt=$(echo "🦷$N:$ds") -} - - -check_network_quarantine() { - # If all wireless devices are (software) blocked, - # change status bar icon and exit - if ! rfkill list | grep -q "Soft blocked: no"; then - echo "🗿" - exit - fi -} - - -check_network_quarantine -set_wlan -set_bt -echo "$wlan$bt" diff --git a/local/bin/scan_loop.sh b/local/bin/scan_loop.sh deleted file mode 100755 index 722e63d..0000000 --- a/local/bin/scan_loop.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# The scan loop is useful when Automatic Document Feeder (ADF) can't be used - -scan_device_uri="hpaio:/net/OfficeJet_Pro_6970?ip=192.168.18.21" -# ^This HP printer is remarkable. It's been working fine since 2017. I refill -# the cardridge with UV ink very easily (I've never purchased ink cardridges -# other than the ones that came with the printer). As of 2023, only the Cyan -# and Black cardridges/inkjets work but Black&White print is all I need. -# And the Linux support and CLI interface is amazing. - - -# Automatic Document Feeder -adf() { - hp-scan --mode=color --resolution=300 --size=a4 --adf #--duplex -} - - -# Scans until terminated with ^C. Saves .png files on CWD. -flatbed_loop() { - echo "Warning: scan loop will run until terminated with Ctrl-C" - i=0 - while true; do - # device show with $ hp-info - hp-scan --mode=color --size=a4 --device=$scan_device_uri - echo "page " $((i + 1)) " done, you have 4 seconds to load next page" - sleep 4 - i=$((expr $i + 1)) - done - # convert *.png output.pdf -} - -flatbed_loop diff --git a/local/bin/screenshot.sh b/local/bin/screenshot.sh deleted file mode 100755 index be4a8f9..0000000 --- a/local/bin/screenshot.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# Takes a screenshot and saves it - -# Inspired by Denshi's screenshot script (https://git.denshi.org/Scripts/tree/screenshot). -# See also https://www.youtube.com/watch?v=uYNTFg3_QaY&t=243s - -savepath="$HOME/media/Pictures/Screenshots" -filename="$HOSTNAME-$(date -Iseconds | tr -d ':-').png" - -if [ "$1" == "screen" ]; then - # capture the screen determined by the cursor location - shotgun -s "$savepath/$filename" -elif [ "$1" == "screens" ]; then - # TODO: This is not currently possible with shotgun 2.5.1 - : -else - # capture a region of the screen - shotgun -g $(hacksaw) "$savepath/$filename" -fi - diff --git a/local/bin/screenshot_ocr.sh b/local/bin/screenshot_ocr.sh deleted file mode 100755 index d88accf..0000000 --- a/local/bin/screenshot_ocr.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Select a region of the screen and perform OCR to it. Save text in clipboard. - -savepath="/tmp/screenshot_ocr.sh.d" -filename="$HOSTNAME-$(date -Iseconds | tr -d ':-').png" -# German: deu, Spanish: spa, Japanese vertical: jpn_vert -tesseract_options="-l eng+jpn" - -_init() { - if [ ! -d "$savepath" ]; then - mkdir -p "$savepath" - fi - cd "$savepath" -} - -_init -# Screenshot region of screen -shotgun -g $(hacksaw) "$filename" -# Exit if previous command was unsuccessful -test $? -ne 0 && exit -# Try to scan codes from the image -zbarimg $filename | xclip -selection "clipboard" -# Perform OCR and save to clipboard -tesseract $tesseract_options $filename - | xclip -selection "clipboard" -rm $filename - -# TODO: clean japanese output. If text is 80% japanese characters, then it -# should not contain spaces around the characters. diff --git a/local/bin/setbg.sh b/local/bin/setbg.sh deleted file mode 100755 index 78cdb2d..0000000 --- a/local/bin/setbg.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# Sets the background (Suckless setup) - -bgfile="$HOME/media/Pictures/Wallpapers/landscapes/japan/Lake_Kawaguchiko_Sakura_Mount_Fuji_3.jpg" -bgfile2="$HOME/media/Pictures/Wallpapers/mine/IMG_20200706_190712.jpg" - -xwallpaper --output eDP --zoom "$bgfile" -xwallpaper --output HDMI-A-0 --zoom "$bgfile2" diff --git a/local/bin/setup_default_apps.sh b/local/bin/setup_default_apps.sh deleted file mode 100755 index 9c58b95..0000000 --- a/local/bin/setup_default_apps.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# Set defaults for xdg-open -# -# For a list of MIME types see https://www.iana.org/assignments/media-types/media-types.xhtml - -# Useful commands: -# xdg-mime query filetype FILE -# xdg-mime query default MIMETYPE - -# File -#pcmanfm - -# Image -xdg-mime default nsxiv.desktop image/bmp image/gif image/jpeg image/jpg image/png image/tiff image/x-bmp image/x-portable-anymap image/x-portable-bitmap image/x-portable-graymap image/x-tga image/x-xpixmap image/webp image/heic image/svg+xml application/postscript image/jp2 image/jxl image/avif image/heif - -# Video -#xdg-mime default mpv.desktop A_LOT_OF_MIME_TYPES - -# Mail -#thunderbird - -# Office -xdg-mime default org.pwmt.zathura.desktop application/pdf application/postscript image/vnd.djvu application/epub+zip -#libreoffice - -# Text -xdg-mime default nvim.desktop text/plain - -# Net -xdg-mime default org.qbittorrent.qBittorrent.desktop application/x-bittorrent x-scheme-handler/magnet diff --git a/local/bin/updatewebsite.sh b/local/bin/updatewebsite.sh deleted file mode 100755 index 71c99b2..0000000 --- a/local/bin/updatewebsite.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# This script syncs local files to my VPS - -# Thank you: https://unix.stackexchange.com/a/2503/347754 -options="-uvrPs --delete-after --copy-links" -targetdir="tokumori.xyz:/var/www" - -rsync $options /home/mitsuo/mahcode/www/tokumori.xyz $targetdir |
