added menu-qalc

This commit is contained in:
Schrottkatze 2022-09-02 20:28:50 +02:00
parent e4b15a3b1a
commit bce7db5f8d
11 changed files with 180 additions and 76 deletions

View file

@ -0,0 +1,21 @@
items="lock screen;log out;toggle picom;shut down;reboot;update all"
selection=$(echo $items | rofi -sep ";" -dmenu)
case $selection in
"lock screen")
i3lock-fancy
;;
"log out")
pkill i3
;;
"toggle picom")
pkill picom || picom --experimental-backend -b
;;
"shut down")
shutdown now
;;
"reboot")
systemctl reboot
;;
esac

View file

@ -0,0 +1,7 @@
register=$(ls $HOME/xmacros | rofi -dmenu)
count=$(echo "2;5;10;20;50;100" | rofi -dmenu -sep ";" -l 5)
for i in $(seq $count); do
echo $i
xmacroplay "$DISPLAY" < $HOME/xmacros/$register
done

View file

@ -0,0 +1,3 @@
register=$(ls $HOME/xmacros | rofi -dmenu)
xmacroplay "$DISPLAY" < $HOME/xmacros/$register

View file

@ -0,0 +1,10 @@
register=$(ls $HOME/xmacros | rofi -dmenu)
count=$(echo "2;5;10;20;50;100" | rofi -dmenu -sep ";" -l 5)
for i in $(seq $count); do
echo $i
xmacroplay "$DISPLAY" < $HOME/xmacros/$register
done
register=$(ls $HOME/xmacros | rofi -dmenu)
xmacrorec2 > $HOME/xmacros/$register

View file

@ -0,0 +1,87 @@
# Copy-pasted from https://raw.githubusercontent.com/BarbUk/menu-qalc/master/%3D
# I hope this is even legal but OH WELL
# https://github.com/onespaceman/menu-calc
# Calculator for use with rofi/dmenu(2)
# Copying to the clipboard requires xclip
usage() {
echo "$(tput bold)menu-calc$(tput sgr0)"
echo "A calculator for Rofi/dmenu(2)"
echo
echo "$(tput bold)Usage:$(tput sgr0)"
echo " = 4+2"
echo " = (4+2)/(4+3)"
echo " = 4^2"
echo " = sqrt(4)"
echo " = c(2)"
echo
echo "$(tput bold)Force Rofi/dmenu(2):$(tput sgr0)"
echo "By default, if rofi exists, it will be used. To force menu-calc to"
echo "use one or the other, use the --dmenu argument"
echo
echo " = --dmenu=<dmenu_executable>"
echo
echo "$(tput bold)Passing arguments to Rofi/dmenu(2):$(tput sgr0)"
echo "Any parameters after ' -- ' will be passed to Rofi/dmenu(2)."
echo
echo " = -- <Rofi/dmenu(2) args>"
echo
echo "The answer can be copied to the clipboard and used for further calculations inside (or outside) Rofi/dmenu."
echo
echo "If launched outside of Rofi/dmenu the expression may need quotation marks."
exit
}
# Process CLI parameters
for var in "$@"
do
case $var in
-h|--help) usage ;;
-d=*|--dmenu=*)
menu=$(echo $var | cut -d'=' -f 2);
;;
--) break ;;
esac
done
# Grab the answer
if [ -n "$1" ]; then
answer=$(echo "$1" | qalc +u8 -color=never -terse | awk '!/^>/ && !/^$/ {gsub(/^[ \t]+|[ \t]+$/, "", $0); print}')
fi
# Path to menu application
if [ -z "${menu+1}" ]; then
if [[ -n $(command -v rofi) ]]; then
menu="$(command -v rofi)"
elif [[ -n $(command -v dmenu) ]]; then
menu=$(command -v dmenu)
else
>&2 echo "Rofi or dmenu not found"
exit
fi
fi
# If using rofi, add the necessary parameters
if [[ $menu == "rofi" || $menu == $(command -v rofi) ]]; then
menu="$menu -dmenu -lines 3"
elif [[ $menu == "dmenu" || $menu == $(command -v dmenu) ]]; then
menu="$menu ""$DMENU_OPTIONS"
fi
# Determine args to pass to dmenu/rofi
while [[ $# -gt 0 && $1 != "--" ]]; do
shift
done
[[ $1 == "--" ]] && shift
action=$(echo -e "Copy to clipboard\nClear\nClose" | $menu "$@" -p "= $answer")
case $action in
"Clear") $0 ;;
"Copy to clipboard") echo -n "$answer" | xclip -selection clipboard ;;
"Close") ;;
"") ;;
*) $0 "$answer $action" "--dmenu=$menu" "--" "$@" ;;
esac

View file

@ -0,0 +1,26 @@
langs="eng deu spa osd"
langs=$(tesseract --list-langs | tail +2)
first_menu="$langs exit"
selection_menu1=$(echo $first_menu | rofi -sep " " -dmenu)
tmp_img=`mktemp`
trap "rm $tmp_img*" EXIT
echo $selection_menu1
case $selection_menu1 in
"eng"|"deu"|"spa"|"osd"|"fra")
tesseract_lang=$selection_menu1
flameshot gui -p $tmp_img.png -d 100
mogrify -modulate 100,0 -resize 400% $tmp_img.png
;;
"exit")
exit
;;
esac
tesseract $tmp_img.png $tmp_img &> /dev/null
xclip -i $tmp_img.txt -selection clipboard
exit

View file

@ -0,0 +1,8 @@
unset x y w h
eval $(xwininfo -id $(xdotool getactivewindow) |
sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
-e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
-e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
-e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )
echo -n "''$x ''$y ''$w ''$h"
flameshot gui --region "''${w}x''${h}+''${x}+''${y}" -c -p ~/Pictures/screenshots/

View file

@ -1 +0,0 @@
with import <nixpkgs> {};