It is currently Fri Jul 19, 2024 11:23 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Linux bash script to have MyPaint-style color picker on stylus button
PostPosted: Wed Jun 13, 2018 5:49 pm  (#1) 
Offline
GimpChat Member

Joined: Aug 17, 2013
Posts: 8
MyPaint has an "instant"/hovering color picker on the stylus button, whereas GIMP gives you the main toolbar menu again, and there's no setting to change it yet, unlike in Krita.

While holding control and then clicking/touching the stylus tip is not really a cumbersome thing to do, if one is used to MyPaint's way, which is slightly more practical, there's a hackish way to do it:

#!/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



That's for my Wacom tablet model specifically, one of the simplest bamboo ones, it needs to be adapted with the proper device names for different models, and I have no idea about non-Wacom tablets.

You just leave the script running as you run GIMP, and it will loop checking whether the focused window has "GIMP" in its title, and if it is, it changes the third button to "control click", which "automates" GIMP's way of activating the color picker, in a way that mimics MyPaint's somewhat. When GIMP is not focused, it restores the button to its default value.

It's not perfect, holding the button and hovering around won't change the color picked on first button click, but it does not require holding control and touching the tip, so it's a much closer dynamic.

Another potential issue is that, while it's running, it will change the stylus button in any window that may have its title ending with "GIMP" for some reason.

It has no output whatsoever on the screen. If you remove ">/dev/null" it will "echo" the active window title containing "GIMP".

Maybe the sleep time can be considerably extended without causing any trouble, to make it lighter, CPU-wise, even though I guess it's not really heavy.



Requires xdotool and xsetwacom.


Last edited by noob on Wed Jun 13, 2018 6:35 pm, edited 2 times in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Linux bash script to have MyPaint-style color picker on stylus but
PostPosted: Wed Jun 13, 2018 6:17 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Nov 04, 2015
Posts: 1366
hi noob,
That's an ingenious way of deciding if the active window is running Gimp. You maybe a bit underwhelmed at the reaction to this bash script but it's now discoverable by people who could enjoy using it.


Top
 Post subject: Re: Linux bash script to have MyPaint-style color picker on stylus but
PostPosted: Wed Jun 13, 2018 6:41 pm  (#3) 
Offline
GimpChat Member

Joined: Aug 17, 2013
Posts: 8
Yeah, I'm not expecting an overwhelming ovation or anything, I just googled for this issue and I found some people who also wanted to have it like that, and someone hinting at a solution more or less along these lines, of reassigning the stylus button, rather than the ideal way. But I'm aware it's not really that useful for most.

I just edited the grep command that matches GIMP's window, by the way, adding a "$" after "GIMP" so it will only match windows with GIMP as the last thing on the title.

I'm not sure how it will play with dialog windows, I don't recall using this button in other parts on the GUI.



Perhaps a moderator/administrator could please move this topic as an answer to this request?

viewtopic.php?f=8&t=15533

If April of 2017 is not "necromancing" too much. Somehow I didn't notice this question was in this very website and somewhat recent, as I posted the topic.


Top
 Post subject: Re: Linux bash script to have MyPaint-style color picker on stylus but
PostPosted: Sat Mar 09, 2019 5:52 pm  (#4) 
Offline
GimpChat Member

Joined: Aug 17, 2013
Posts: 8
I've updated/improved and expanded this script. Or yet, incorporated the principle into another, that may be of interest on those who'd like if GIMP had a few features more similar to MyPaint or Krita, namely this color-picking with the stylus button click, without holding "control" on the keyboard, but also some extra buttons such as undo, redo, zomm in, zoom out, mirror view, and deselect.

The color-picker part is also improved regarding how the script distinguishes between the GIMP image window versus some others, which in this old version would have the "right click" stylus button affected, transformed into an inherent Ctrl+button.

Here's a screen capture of the new toolbar I did with "YAD":

http://i67.tinypic.com/k3ukqx.jpg

And my entire setup, really which I guess is pretty much non-standard.

Here's a link to the "source code" of the script and additional notes.

https://www.linuxquestions.org/question ... ion-37940/

It's not something that many people would even like, and it will probably require some considerable adaptation if one also isn't using Linux and an Openbox "desktop environment"/window manager. It also has some specific configurations for my own screen size.

Regardless, it may be of interest for those who like the general idea and know enough to adapt to their own configuration.





I wonder if all of it or at least part of it couldn't be achieved with a Python plugin, it would make it much more "portable" for anyone who's not me and even for myself in eventual hardware upgrades or different desktop environments.


Top
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugin

87

No new posts Attachment(s) Color Picker

7

No new posts Attachment(s) Lab colorspace, color picker.

3

No new posts Attachment(s) Please Help, I Cannot get the correct value using the color picker.

4

No new posts Attachment(s) Can't get color picker to work [Solved]

7



* Login  



Powered by phpBB3 © phpBB Group