LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

Proof of concept script to make GIMP more similar to MyPaint or Krita, for painting/drawing

Posted 06-13-2018 at 03:37 PM by the dsc
Updated 06-13-2018 at 04:36 PM by the dsc

Apparently on GIMP you can't set the stylus button 3 as an instant color picker. The default is to hold control and click, which is not that much of a hassle, but it's interesting to have this kind of functionality more uniformly activated.

A hacky way of getting an approximation of it is along the line(s) of:

Code:
while true ; do xdotool getactivewindow getwindowname | grep GIMP && xsetwacom set "Wacom Bamboo Pen stylus" Button 3 "key Control button 1" || xsetwacom set "Wacom Bamboo Pen stylus" Button 3 "button 3" ; sleep 0.3 ; done
For better reading, NOT for copy/paste:

while true ; do xdotool getactivewindow getwindowname | grep GIMP &&
xsetwacom set "Wacom Bamboo Pen stylus" Button 3 "key Control button 1" ||
xsetwacom set "Wacom Bamboo Pen stylus" Button 3 "button 3" ; sleep 0.3 ; done


Which would run as a wrap-around script on GIMP, I guess.

It possibly can be improved by assigning a random variable as an "on/off" thing so to avoid issuing the same command all the time, skipping xsetwacom itself.

Needless to say, you lose the "right click" menu with the stylus while it runs, even though it's still accessible on the mouse and on the menu bar itself, if it's not hidden.


Ideally I'd hack GIMP's code and make it a thing that can be configured for real, though, but that's well beyond my capabilities right now.


_____________

Okay, here's a more refined script, that uses a variable in order to skip or not issuing xsetwacom:

Code:
#!/bin/bash

xsetwlock=0

while true ; do 

if xdotool getactivewindow getwindowname | grep GIMP > /dev/null  ; then
	if ((xsetwlock==0)) ; then
		 xsetwacom set "Wacom Bamboo Pen stylus" Button 3 "key Control button 1" 
		 xsetwlock=1 
	fi
else
	if ((xsetwlock==1)) ; then
		xsetwacom set "Wacom Bamboo Pen stylus" Button 3 "button 3"
		xsetwlock=0 
	fi

fi

sleep 0.3 

 done
It would possibly be improved in terms of CPU load by replacing some if/then/else phrasings with just concatenated "&&" and "||", like the original, but I couldn't do the lock thing work that way, it's somewhat more confusing to write it. In the other hand, maybe the if/fis thing make it consume more CPU than issuing xsetwacom all the time, I haven't checked.

But I don't even know if it makes that much of a difference, it may well be worse.
Posted in Uncategorized
Views 1616 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 06:34 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration