wacom tablet setup script for x, organize aliases

This commit is contained in:
tavo-wasd 2023-09-24 17:26:39 -06:00
parent a003b64db8
commit 0ac768285d
3 changed files with 50 additions and 8 deletions

41
scripts/wacom-setup Executable file
View file

@ -0,0 +1,41 @@
#!/bin/sh
# Set Wacom tablet parameters
# for 1:1 drawing, X11 script
WACOM_ID="$1"
WACOM_SCREEN="$2"
# If first argument is 'menu', choose parameters with a graphical menu
if [ "$WACOM_ID" = "menu" ] ; then
WACOM_ID="$(xsetwacom list devices | menu "Device:" | grep -o 'id:.*:' | grep -o '[0-9]*')"
WACOM_SCREEN="$(xrandr | grep -o '[0-9]*x[0-9]*+[0-9]*+[0-9]*' | menu "Screen:")"
fi
# If required fields are empty, quit with help message
if [ "$WACOM_ID" = "" -o "$WACOM_SCREEN" = "" ] ; then
printf "Usage: wacom_pen_setup [ID] [SCREEN]\n"
printf "\033[1m\nDEVICES:\033[0m\n"
xsetwacom list devices
SCREENS="$(xrandr | grep -o '[0-9]*x[0-9]*+[0-9]*+[0-9]*' | tr '\n' ' ')"
printf "\033[1m\nSCREENS:\033[0m\n"
for SCREEN in $SCREENS ; do
printf "%s\n" "$SCREEN"
done
return 0
fi
# Define $SCREEN dimensions
SCREEN_W="${WACOM_SCREEN%%x*}"
SCREEN_H="${WACOM_SCREEN##*x}"
SCREEN_H="${SCREEN_H%%+*}"
# Define proper tablet dimensions with screen aspect ratio
WACOM_W="$(xsetwacom get $WACOM_ID area | cut -d ' ' -f 3)"
WACOM_H="$(printf %d\\n "$((${WACOM_W} * ${SCREEN_H}/${SCREEN_W}))")"
# Configure tablet, notify if there's an error
xsetwacom set "$WACOM_ID" MapToOutput "$WACOM_SCREEN" || notify-send "wacom_pen_setup" "Error occured while setting screen"
xsetwacom set "$WACOM_ID" Area 0 0 "$WACOM_W" "$WACOM_H" || notify-send "wacom_pen_setup" "Error occured while setting tablet dimensions"

View file

@ -17,7 +17,6 @@ alias \
# Common
alias \
df-short="df -h | grep -v '\s/dev.*$\|\s/run.*$\|\s/boot.*$'" \
ls="exa -al --group-directories-first" \
fzf="fzf --cycle --reverse" \
diff="diff --color=auto" \
@ -28,14 +27,15 @@ alias \
rm="rm -iv" \
vim="nvim" \
# Command shortcuts
alias \
apt-upgrade="sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y" \
df-short="df -h | grep -v '\s/dev.*$\|\s/run.*$\|\s/boot.*$'" \
wacom-setup-menu="wacom-setup menu" \
notes="note list" \
def="dict" \
# Launch args
alias \
fzf-edit-script="fzf_nav /home/$(whoami)/.config/scripts" \
newsboat="newsboat -u ~/Documents/personal/rss" \
notes="note list" \
def="dict" \
# Command shortcuts
alias \
apt-upgrade="sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y" \

View file

@ -35,3 +35,4 @@ history 50 |
$SHELL |
xsel -ib
}