From d5a6aeef74b387c6e4984dd81a1f0039f8425549 Mon Sep 17 00:00:00 2001 From: John Gebbie Date: Tue, 12 Sep 2023 12:49:35 +0100 Subject: [PATCH] init modifiers --- dotool.go | 20 ++++++++++---------- keys.go | 7 +++++++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/dotool.go b/dotool.go index cc93d94..7713625 100644 --- a/dotool.go +++ b/dotool.go @@ -113,38 +113,38 @@ func parseChord(keymap *xkb.Keymap, chord string) (Chord, error) { func (c *Chord) KeyDown(kb uinput.Keyboard) { if c.Super { - log(kb.KeyDown(uinput.KeyLeftmeta)) + log(kb.KeyDown(super)) } if c.AltGr { - log(kb.KeyDown(84)) + log(kb.KeyDown(altgr)) } if c.Ctrl { - log(kb.KeyDown(uinput.KeyLeftctrl)) + log(kb.KeyDown(ctrl)) } if c.Alt { - log(kb.KeyDown(uinput.KeyLeftalt)) + log(kb.KeyDown(alt)) } if c.Shift { - log(kb.KeyDown(uinput.KeyLeftshift)) + log(kb.KeyDown(shift)) } log(kb.KeyDown(c.Key)) } func (c *Chord) KeyUp(kb uinput.Keyboard) { if c.Super { - log(kb.KeyUp(uinput.KeyLeftmeta)) + log(kb.KeyUp(super)) } if c.AltGr { - log(kb.KeyUp(84)) + log(kb.KeyUp(altgr)) } if c.Ctrl { - log(kb.KeyUp(uinput.KeyLeftctrl)) + log(kb.KeyUp(ctrl)) } if c.Alt { - log(kb.KeyUp(uinput.KeyLeftalt)) + log(kb.KeyUp(alt)) } if c.Shift { - log(kb.KeyUp(uinput.KeyLeftshift)) + log(kb.KeyUp(shift)) } log(kb.KeyUp(c.Key)) } diff --git a/keys.go b/keys.go index eca9215..5b1346c 100644 --- a/keys.go +++ b/keys.go @@ -6,6 +6,8 @@ import ( "unicode" ) +var super, altgr, ctrl, alt, shift int + var LinuxKeys = map[string]Chord{ // Linux Only "micmute": Chord{Key: uinput.KeyMicmute}, @@ -641,6 +643,11 @@ func initKeys(keymap *xkb.Keymap) { } } } + super = XKeys["Super_L"].Key + altgr = XKeys["ISO_Level3_Shift"].Key + ctrl = XKeys["Control_L"].Key + alt = XKeys["Alt_L"].Key + shift = XKeys["Shift_L"].Key } func getChord(keymap *xkb.Keymap, keysym uint32) Chord {