I want to use the top button of my Bamboo Ink pen, which triggers a Bluetooth connection when being presses and closes the connection when released. I already got this working, but there are a few issues. I have made a udev rule that starts a script on a bluetooth connection event.
This script calls the actual script to prevent queuing of the udev events and sets the right locale (if necessary)
#!/bin/bash
export LC_ALL=de_DE.UTF-8
echo /home/user/runXournalpp | at now
The script starts Xournal++ and maps the Wacom tablet to the Laptop monitor. If called a second time it maximizes Xournal++.
#!/bin/bash
export DISPLAY=":0"
if pgrep xournalpp
then
echo Xournal++ is running
wmctrl -x -a com.github.xournalpp.xournalpp
wmctrl -x -r com.github.xournalpp.xournalpp -b "add,maximized_vert,maximized_horz"
else
echo Xournal++ is not running
xsetwacom --set "Wacom Pen and multitouch sensor Pen stylus" MapToOutput "eDP1"
xsetwacom --set "Wacom Pen and multitouch sensor Pen eraser" MapToOutput "eDP1"
xsetwacom --set "Wacom Pen and multitouch sensor Finger touch" MapToOutput "eDP1"
xournalpp
fi
Three issues remain:
1. Udev also triggers an event when waking from sleep mode.
2. It causes graphical glitches in Vivaldi, resulting in flickering colors of the tab bar. Haven’t found another app that has these glitches. No idea why this happens.
3. “Recent documents” are not shown in the application. It seems that the app is loaded by a different user.
So I am wondering if there is a better way to realize this. This is a pretty hacky solution. I guess there is some command sent via Bluetooth that I could find out with Wireshark. I don’t know how I would make the OS read and react to that command though.
I’m trying to launch vlc/audacious when my bt speaker connects to automatically play radio playlist. My udev rule is very simillar to the one above and it will launch my application. But that’s where my problems begin. Vlc/Audacious is shown without any theming, network & audio do not work etc.
I’m sorry, but I thought the idea of forums is to help community not only some users. And since my problem is exactly what topic title says and my problems are probably somewhat related I posted in this topic. Or do I have to open another topic with exactly the same title?
You are probably opening vlc as root by using XAUTHORITY and thus the theme is gone. Use a script to start vlc with the locale as in my example. Then call this from udev with ENV{HOME}. This might result in queuing of the events. It is really tricky. I think udev wasn‘t designed for running graphical applications.
I guess my title is too general. I have a specific problem that requires a specific solution. Our problems are similar though. I don’t mind you posting it here as well.
@Fabby: I found the solution to the udev triggering on wakeup. Seems I didn’t specify the device enough as you suspected. When you gather device information with udevadm info -ap /dev/path, you need to take the entry at the top. All the other following a parent devices apparently. It though that using ATTRS{idVendor} and ATTRS}idProduct} would be the most specific but I was wrong.