summaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-12-06 01:30:57 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-12-06 01:30:57 +0100
commit02e4686ccd7c95c6df855be61496c75c92b11396 (patch)
tree10ef22afb440b6f91e695d25677f130a5a79f75f /.local/bin
parentd9f33332f52a60130325a5d16785ee9577647d42 (diff)
scripts: Move many scripts from sh to andy
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/chkb26
-rwxr-xr-x.local/bin/ec4
-rwxr-xr-x.local/bin/osel5
-rwxr-xr-x.local/bin/qotd43
-rwxr-xr-x.local/bin/woman24
5 files changed, 49 insertions, 53 deletions
diff --git a/.local/bin/chkb b/.local/bin/chkb
index d38aaa8..359f443 100755
--- a/.local/bin/chkb
+++ b/.local/bin/chkb
@@ -1,26 +1,26 @@
-#!/bin/sh
+#!/usr/local/bin/andy
-set -e
+set -e NOTIFY_LONG keyboard
+set -e NOTIFY_SHORT chkb
-export NOTIFY_LONG=keyboard
-export NOTIFY_SHORT=${0##*/}
+set KEYBOARD at-translated-set-2-keyboard
-readonly KEYBOARD=at-translated-set-2-keyboard
-
-s="$(
+set s `{
{
hyprctl -j getoption input:kb_layout
hyprctl -j getoption input:kb_variant
- } | jq -rn '
+ }
+ | jq -rn '
[inputs]
| map(.str | split(",\\s*"; "g"))
| transpose
| map("\(.[0]) (\(.[1]))")
| .[]
- ' | sed -E 's/[a-zA-Z]+/\u&/g'
-)"
+ '
+ | sed -E 's/[a-zA-Z]+/\u&/g'
+}
-choice="$(echo "$s" | osel)"
-n="$(echo "$s" | sed -n "/$choice/=" | { xargs expr -1 + || true; })"
-hyprctl switchxkblayout $KEYBOARD $n >/dev/null
+set choice `echo $s | osel
+set n `echo $s | sed -n "/$choice/=" | { xargs expr -1 + || true }
+hyprctl switchxkblayout $KEYBOARD $n >_
notify 'Keyboard Layout Changed' "The keyboard layout was changed to ‘$choice’"
diff --git a/.local/bin/ec b/.local/bin/ec
index 0e748af..5190e05 100755
--- a/.local/bin/ec
+++ b/.local/bin/ec
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/local/bin/andy
-[ -t 2 ] && mode=t || mode=c
+test -t 2 && set mode t || set mode c
exec emacsclient -s ec -$mode
diff --git a/.local/bin/osel b/.local/bin/osel
index ca2727f..ccabc96 100755
--- a/.local/bin/osel
+++ b/.local/bin/osel
@@ -6,12 +6,11 @@ index()
{
if [ -t 2 ]
then
- nl -nln -w1 \
+ nl -nln -w1 -v0 \
| eval fzf --with-nth=2.. $OSEL_TERM_FLAGS \
| cut -f1
else
- eval fuzzel --index $OSEL_GUI_FLAGS \
- | xargs expr 1 +
+ eval fuzzel --index $OSEL_GUI_FLAGS
fi
}
diff --git a/.local/bin/qotd b/.local/bin/qotd
index fed3297..7bf6e03 100755
--- a/.local/bin/qotd
+++ b/.local/bin/qotd
@@ -1,30 +1,23 @@
-#!/bin/sh
+#!/usr/local/bin/andy
-set -e
-
-older_than_today()
-{
- if [ ! -f "$1" ]
- then
- mod=0000-00-00
- else
- mod=`stat -c %y "$1" | xargs -I{} -- date -d{} +%F`
- fi
-
- [ $mod != `date +%F` ]
- return $?
+func older_than_today file {
+ if test ! -f $file {
+ set mod 0000-00-00
+ } else {
+ set mod `stat -c %y $file | xargs -I{} -- date -d{} +%F
+ }
+ test $mod != `date +%F
}
-readonly QUOTES="${XDG_DATA_HOME:-$HOME/.local/share}/romir/quotes.yml"
-readonly QOTD="${XDG_CACHE_HOME:-$HOME/.cache}/qotd"
+set QUOTES $XDG_DATA_HOME/romir/quotes.yml
+set QOTD $XDG_CACHE_HOME/qotd
-if older_than_today "$QUOTES"
-then
- dirname "$QUOTES" | xargs mkdir -p
- chronic wget 'https://romir.eu/mangoes.yaml' -O "$QUOTES"
-fi
+if older_than_today $QUOTES {
+ mkdir -p `dirname $QUOTES
+ chronic wget 'https://romir.eu/mangoes.yaml' -O $QUOTES
+}
-older_than_today "$QOTD" \
- && yq -0 '.mangoes.[].quote.content' <"$QUOTES" \
- | shuf -zn1 \
- | tr '\0' '\n' >"$QOTD"
+older_than_today $QOTD
+&& yq -0 '.mangoes.[].quote.content' <$QUOTES
+| shuf -zn1
+| tr '\0' '\n' >$QOTD
diff --git a/.local/bin/woman b/.local/bin/woman
index bbabc8e..c68728d 100755
--- a/.local/bin/woman
+++ b/.local/bin/woman
@@ -1,12 +1,16 @@
-#!/bin/sh
+#!/usr/local/bin/andy
-apropos . \
-| sed -E 's/ (\([^)]+\))\s*-/\1 —/' \
-| sort \
-| osel \
-| sed 's/\s.*//' \
-| {
- IFS= read -r page
- [ -n "$page" -a ! -t 2 ] && man -Tpdf "$page" | zathura -
- [ -n "$page" -a -t 2 ] && man "$page"
+# TODO: -s flag to apropos
+
+apropos .
+| sed -E 's/ (\([^)]+\))\s*-/\1 —/'
+| sort
+| osel
+| sed 's/\s.*//'
+| read page
+
+if test -n $page -a ! -t 2 {
+ man -Tpdf $page | zathura -
+} else if test -n $page -a -t 2 {
+ man $page
}