wacom-emoji now literate programming, fixed issue with rofi-emoji
This commit is contained in:
parent
825c41e5b2
commit
317eca7eb1
@ -62,6 +62,11 @@
|
||||
- [[#ask-what-type-of-drive-to-unmount][Ask what type of drive to unmount]]
|
||||
- [[#launch-the-unmounting-functions][Launch the unmounting functions]]
|
||||
- [[#starwars][Starwars]]
|
||||
- [[#wacom-setup][Wacom setup]]
|
||||
- [[#set-our-variables][Set our variables]]
|
||||
- [[#select-our-screen][Select our screen]]
|
||||
- [[#adjust-the-tablet][Adjust the tablet]]
|
||||
- [[#lauch-the-functions][Lauch the functions]]
|
||||
|
||||
* Presentation
|
||||
:PROPERTIES:
|
||||
@ -771,3 +776,171 @@
|
||||
#!/usr/bin/fish
|
||||
telnet towel.blinkenlights.nl
|
||||
#+END_SRC
|
||||
|
||||
* Wacom setup
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: h-e407ceef-2f14-4474-916b-6b687cf9f2e9
|
||||
:HEADER-ARGS: :tangle wacom-setup :exports code
|
||||
:END:
|
||||
I made a small and quick utility to set up my Wacom tablet so it is only bound
|
||||
to one screen. This is a fish script, so let’s insert the sheband.
|
||||
#+BEGIN_SRC fish
|
||||
#!/usr/bin/fish
|
||||
#+END_SRC
|
||||
|
||||
** Set our variables
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: h-c46f0eaf-ae46-4595-8d7a-944bc789cc06
|
||||
:END:
|
||||
Let’s first declare our function that will be called to set our variables.
|
||||
#+BEGIN_SRC fish
|
||||
function set_device
|
||||
#+END_SRC
|
||||
|
||||
We need some variables in order to correctly set our tablet. First, let’s get
|
||||
declare what the name of our tablet is, and what the name of its touchpad is.
|
||||
#+BEGIN_SRC fish
|
||||
set -g DEVICE "Wacom USB Bamboo PAD Pen stylus"
|
||||
set -g DEVICETOUCH "Wacom USB Bamboo PAD Finger touch"
|
||||
#+END_SRC
|
||||
|
||||
We will also modify two settings: the speed of the cursor on the touchpad,
|
||||
and the scroll speed. Let’s declare the name of these two settings.
|
||||
#+BEGIN_SRC fish
|
||||
set -g WACOMPROPTOUCHSPEED "Device Accel Velocity Scaling"
|
||||
set -g WACOMPROPSCROLLPSEED "ScrollDistance"
|
||||
#+END_SRC
|
||||
|
||||
To get the correct values for the area it can cover, we’ll need to reset our
|
||||
tablet.
|
||||
#+BEGIN_SRC fish
|
||||
xsetwacom set "$DEVICE" ResetArea
|
||||
#+END_SRC
|
||||
|
||||
Now we can get the X and Y areas.
|
||||
#+BEGIN_SRC fish
|
||||
set -l AREATOT (xsetwacom get "$DEVICE" Area)
|
||||
set -g AREAX (echo $AREATOT | awk '{print $3}')
|
||||
set -g AREAY (echo $AREATOT | awk '{print $4}')
|
||||
#+END_SRC
|
||||
|
||||
Now let’s close our function.
|
||||
#+BEGIN_SRC fish
|
||||
end
|
||||
#+END_SRC
|
||||
|
||||
** Select our screen
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: h-c81850ec-b2dd-4c57-8570-aca14ca4061b
|
||||
:END:
|
||||
This function will allow us to select the screen on which the tablet will be
|
||||
active. We can also select the option “desktop” so that all screens are
|
||||
selected. Let’s declare our function.
|
||||
#+BEGIN_SRC fish
|
||||
function set_screen
|
||||
#+END_SRC
|
||||
|
||||
First, let’s set what screens are available, including the desktop option.
|
||||
#+BEGIN_SRC fish
|
||||
set CONNECTED_DISPLAYS (xrandr -q --current | \
|
||||
sed -n 's/^\([^ ]\+\) connected .*/\1/p') desktop
|
||||
#+END_SRC
|
||||
|
||||
Now, let’s select the one we wish to use using rofi.
|
||||
#+BEGIN_SRC fish
|
||||
set -g SCREEN (for d in $CONNECTED_DISPLAYS
|
||||
echo $d
|
||||
end | rofi -dmenu -i -p "Select your dispaly" | tr -d '\n')
|
||||
#+END_SRC
|
||||
|
||||
Now, let’s get the resolution of our selected screen.
|
||||
#+BEGIN_SRC fish
|
||||
set -l LINE (xrandr -q --current | if [ "$SCREEN" = "desktop" ]
|
||||
sed -n 's/^Screen 0:.*, current \([0-9]\+\) x \([0-9]\+\),.*/\1 \2/p'
|
||||
else
|
||||
sed -n "s/^$SCREEN"' connected \(primary \)\{0,1\}\([0-9]\+\)x\([0-9]\+\)+.*/\2 \3/p'
|
||||
end)
|
||||
#+END_SRC
|
||||
|
||||
From that, let’s get the vertical and horizontal resolution of our screen.
|
||||
#+BEGIN_SRC fish
|
||||
echo $LINE | read -g WIDTH HEIGHT
|
||||
#+END_SRC
|
||||
|
||||
If any of our =WIDTH= ou =HEIGHT= it empty, we’ll have to abort the script.
|
||||
#+BEGIN_SRC fish
|
||||
if test -z $WIDTH || test -z $HEIGHT
|
||||
exit 1
|
||||
end
|
||||
#+END_SRC
|
||||
|
||||
Let’s close our function now.
|
||||
#+BEGIN_SRC fish
|
||||
end
|
||||
#+END_SRC
|
||||
|
||||
** Adjust the tablet
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: h-7e7bcdd1-dce8-43aa-b26e-cc4f38be2a1b
|
||||
:END:
|
||||
This function will take care of adjusting our tablet to our screen. Let’s
|
||||
declare our function.
|
||||
#+BEGIN_SRC fish
|
||||
function adjust_device
|
||||
#+END_SRC
|
||||
|
||||
If our screen is too high or too wide for our tablet, we will have to adjust
|
||||
the height or width of the area used by the tablet. So let’s get the
|
||||
theoretical new height and width of the area.
|
||||
#+BEGIN_SRC fish
|
||||
set RATIOAREAY (math ceil \($AREAX \* $HEIGHT \/ $WIDTH\))
|
||||
set RATIOAREAX (math ceil \($AREAY \* $WIDTH \/ $HEIGHT\))
|
||||
#+END_SRC
|
||||
|
||||
Now, if the current height of the tablet’s area is greater than the
|
||||
theoretical new area, it means the current area is too high. Otherwise, it
|
||||
should be the other way around. Let’s set =NEWAREAX= and =NEWAREAY= that will
|
||||
be used to set the new area for the tablet.
|
||||
|
||||
#+BEGIN_SRC fish
|
||||
if test $AREAY -gt $RATIOAREAY
|
||||
set -g NEWAREAX $AREAX
|
||||
set -g NEWAREAY $RATIOAREAY
|
||||
else
|
||||
set -g NEWAREAX $RATIOAREAX
|
||||
set -g NEWAREAY $AREAY
|
||||
end
|
||||
#+END_SRC
|
||||
|
||||
Alright, now let’s set the new area with these new variables.
|
||||
#+BEGIN_SRC fish
|
||||
xsetwacom set "$DEVICE" Area 0 0 $NEWAREAX $NEWAREAY
|
||||
xsetwacom set "$DEVICE" MapToOutput "$SCREEN"
|
||||
#+END_SRC
|
||||
|
||||
Let’s slow down the cursor’s speed on the touchpad.
|
||||
#+BEGIN_SRC fish
|
||||
xinput set-float-prop $DEVICETOUCH $WACOMPROPTOUCHSPEED 0.5
|
||||
#+END_SRC
|
||||
|
||||
Let’s also slow down the scroll speed of the touchpad.
|
||||
#+BEGIN_SRC fish
|
||||
xsetwacom set $DEVICETOUCH $WACOMPROPSCROLLPSEED "90"
|
||||
#+END_SRC
|
||||
|
||||
Now, let’s close the function.
|
||||
#+BEGIN_SRC fish
|
||||
end
|
||||
#+END_SRC
|
||||
|
||||
** Lauch the functions
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: h-e8699018-acf1-42f9-9ce7-4f7bd1a83f9c
|
||||
:END:
|
||||
Back to the main body of the script, we can now launch the functions
|
||||
sequencially.
|
||||
#+BEGIN_SRC fish
|
||||
set_device
|
||||
set_screen
|
||||
adjust_device
|
||||
#+END_SRC
|
||||
|
@ -2,6 +2,6 @@
|
||||
grep -v "#" ~/.config/emoji.txt | rofi -dmenu -i | awk '{print $1}' | tr -d '\n' | xclip -selection clipboard
|
||||
|
||||
set emoji (xclip -o -selection clipboard | tr -d '\n')
|
||||
test -z "$emoji" && exit
|
||||
test -z "$emoji" && notify-send "No emoji copied" && exit
|
||||
set -a emoji "copied to clipboard"
|
||||
pgrep -x dunst >/dev/null && notify-send $emoji
|
||||
|
@ -1,32 +1,46 @@
|
||||
#!/usr/bin/fish
|
||||
|
||||
function set_device
|
||||
|
||||
set -g DEVICE "Wacom USB Bamboo PAD Pen stylus"
|
||||
set -g DEVICETOUCH "Wacom USB Bamboo PAD Finger touch"
|
||||
|
||||
set -g WACOMPROPTOUCHSPEED "Device Accel Velocity Scaling"
|
||||
set -g WACOMPROPSCROLLPSEED "ScrollDistance"
|
||||
|
||||
xsetwacom set "$DEVICE" ResetArea
|
||||
set AREATOT (xsetwacom get "$DEVICE" Area)
|
||||
|
||||
set -l AREATOT (xsetwacom get "$DEVICE" Area)
|
||||
set -g AREAX (echo $AREATOT | awk '{print $3}')
|
||||
set -g AREAY (echo $AREATOT | awk '{print $4}')
|
||||
|
||||
end
|
||||
|
||||
function set_screen
|
||||
set CONNECTED_DISPLAYS (xrandr -q --current | sed -n 's/^\([^ ]\+\) connected .*/\1/p') desktop
|
||||
|
||||
set CONNECTED_DISPLAYS (xrandr -q --current | \
|
||||
sed -n 's/^\([^ ]\+\) connected .*/\1/p') desktop
|
||||
|
||||
set -g SCREEN (for d in $CONNECTED_DISPLAYS
|
||||
echo $d
|
||||
end | rofi -dmenu -i -p "Select your dispaly" | tr -d '\n')
|
||||
set -g LINE (xrandr -q --current | if [ "$SCREEN" = desktop ]
|
||||
|
||||
set -l LINE (xrandr -q --current | if [ "$SCREEN" = "desktop" ]
|
||||
sed -n 's/^Screen 0:.*, current \([0-9]\+\) x \([0-9]\+\),.*/\1 \2/p'
|
||||
else
|
||||
sed -n "s/^$SCREEN"' connected \(primary \)\{0,1\}\([0-9]\+\)x\([0-9]\+\)+.*/\2 \3/p'
|
||||
end)
|
||||
|
||||
echo $LINE | read -g WIDTH HEIGHT
|
||||
|
||||
if test -z $WIDTH || test -z $HEIGHT
|
||||
return 1
|
||||
exit 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function adjust_device
|
||||
|
||||
set RATIOAREAY (math ceil \($AREAX \* $HEIGHT \/ $WIDTH\))
|
||||
set RATIOAREAX (math ceil \($AREAY \* $WIDTH \/ $HEIGHT\))
|
||||
|
||||
@ -41,11 +55,10 @@ function adjust_device
|
||||
xsetwacom set "$DEVICE" Area 0 0 $NEWAREAX $NEWAREAY
|
||||
xsetwacom set "$DEVICE" MapToOutput "$SCREEN"
|
||||
|
||||
# slow down touchpad
|
||||
xinput set-float-prop $DEVICETOUCH $WACOMPROPTOUCHSPEED 0.5
|
||||
|
||||
# slow down scrolling speed
|
||||
xsetwacom set $DEVICETOUCH "ScrollDistance" "90"
|
||||
xsetwacom set $DEVICETOUCH $WACOMPROPSCROLLPSEED "90"
|
||||
|
||||
end
|
||||
|
||||
set_device
|
||||
|
Loading…
Reference in New Issue
Block a user