News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.

Post Reply  Post Thread 
basic wacom mapper (linux/osx-i-assume)
Author Message
Senior Member

Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
basic wacom mapper (linux/osx-i-assume)

Long time since i've done any coding, but i needed a small and simple way to switch my wacom stylus back and forth between monitors. This script can probably use some tweaks and features, but it works for me for now.

It requires xsetwacom and xrandr, which I'm guessing are available in OSX...not likely Windows.

And I'm still using tooltips as a kludge for getting table labels in a my_function(self) situation. It seems to me that my_table[self:value()] should work, but it always seems to return my_table[1]
EDIT: After thinking more about it, i suppose it would be impossible to automatically determine a widget's index in a table, without doing a loop comparison, considering a widget could be part of any number of tables, or none. I think in the future i'll go with just using a simple "HDMI1" naming of the widget, and put any additional information in a separate widget...then i can get the proper monitor just with self:label() with it if you like...

#!/usr/bin/env murgaLua

-- mikshaw, dec 2013
-- simple GUI for picking a monitor on which to map a wacom stylus
-- connected monitors must already be mapped to the screen for this to work
-- requires xsetwacom and xrandr

-- Whatever device you want to map
wacom = "Wacom Intuos PT M Pen stylus"

monitor = {}
monitor[1] = "LVDS1"
monitor[2] = "VGA1"
monitor[3] = "HDMI1"
monitor[4] = "DP1"

-- Check for Wacom tablet
xsetwacom = io.popen("xsetwacom --list")
xsetwacom_string = xsetwacom:read("*a")
have_wacom    = string.find(xsetwacom_string, wacom)
if not have_wacom then fltk.fl_message("Wacom is not connected"); os.exit(1) end

function set_wacom(self)
-- I still don't know how to grab a table value from self, so i use a tooltip
os.execute("xsetwacom --set \""..wacom.."\" MapToOutput "..self:tooltip())

w = fltk:Fl_Double_Window(500, 300, "screen control")

space = 30
row = space
wacom_status    = fltk:Fl_Box(10, 10, 20, 20, wacom.." connected.")
wacom_status2   = fltk:Fl_Box(10, row, 20, 20, "Map to:")

-- Check for monitors
xrandr = io.popen("xrandr -q")
xrandr_string = xrandr:read("*a")
m_label = {}
for i = 1, #monitor do
    row = row + space
    m_label[i] = fltk:Fl_Radio_Round_Button(10, row, w:w()-20, space, monitor[i])
    if string.find(xrandr_string, monitor[i].." connected") then
        m_label[i]:label(monitor[i].." (connected)")
        m_label[i]:label(monitor[i].." (disconnected)")



This post was last modified: 01-01-2014 03:34 AM by mikshaw.

01-01-2014 02:30 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
basic wacom mapper (linux/osx-i-assume) - mikshaw - 01-01-2014 02:30 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: