diff --git a/scripts/wacom-setup b/scripts/wacom-setup new file mode 100755 index 0000000..af6736a --- /dev/null +++ b/scripts/wacom-setup @@ -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" + diff --git a/shell/aliasrc b/shell/aliasrc index 3aed7a5..9a94ffb 100644 --- a/shell/aliasrc +++ b/shell/aliasrc @@ -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" \ - diff --git a/shell/functions b/shell/functions index 84d0328..f281a1a 100644 --- a/shell/functions +++ b/shell/functions @@ -35,3 +35,4 @@ history 50 | $SHELL | xsel -ib } +