]> oss.titaniummirror.com Git - dispcfg.git/commitdiff
Call setctrl to swap keys
authorR. Steve McKown <rsmckown@gmail.com>
Fri, 23 Jan 2015 11:02:37 +0000 (04:02 -0700)
committerR. Steve McKown <rsmckown@gmail.com>
Fri, 23 Jan 2015 11:02:37 +0000 (04:02 -0700)
Works based on the presence of a CM Storm keyboard

configure_displays
setctrl [new file with mode: 0755]

index 34f3762862f9749c3189b7198937c581211d98cb..dac120459922366d8d02846cb0d2bad06672df5d 100755 (executable)
@@ -189,5 +189,8 @@ if __name__ == '__main__':
                 enabled_count -= disable_an_entry(outputs)
             enabled_count += enable_an_entry(outputs, enabled_count < 2)
 
+        # A hack to set Control/Win key mapping
+        subprocess.call('/usr/local/bin/setctrl')
+
 
     main(sys.argv)
diff --git a/setctrl b/setctrl
new file mode 100755 (executable)
index 0000000..77d5ae3
--- /dev/null
+++ b/setctrl
@@ -0,0 +1,42 @@
+#!/bin/bash
+# Set the Control/Win key swap state.  This is a hack of a script.
+# If the CM Storm keyboard is present, swap Control and Win (Super) keys.  If
+# this keyboard is not present, unswap.  Steve's CM Storm keyboard has had its
+# Control and Win keycaps swapped, as the proper Control key locations are, on
+# this keyboard, where the Windows keys are by default.
+
+swapctrl()
+{
+xmodmap -e "clear Control"
+xmodmap -e "clear Mod4"
+xmodmap -e "keycode 133 = Control_L NoSymbol Control_L"
+xmodmap -e "keycode  37 = Super_L NoSymbol Super_L"
+xmodmap -e "keycode 134 = Control_R NoSymbol Control_R"
+xmodmap -e "keycode 105 = Super_R NoSymbol Super_R"
+xmodmap -e "keycode 206 ="
+xmodmap -e "add Control = Control_L Control_R"
+xmodmap -e "add Mod4 = Super_L Super_R"
+}
+
+unswapctrl()
+{
+xmodmap -e "clear Control"
+xmodmap -e "clear Mod4"
+xmodmap -e "keycode  37 = Control_L NoSymbol Control_L"
+xmodmap -e "keycode 133 = Super_L NoSymbol Super_L"
+xmodmap -e "keycode 206 = NoSymbol Super_L NoSymbol Super_L"
+xmodmap -e "keycode 105 = Control_R NoSymbol Control_R"
+xmodmap -e "keycode 134 = Super_R NoSymbol Super_R"
+xmodmap -e "add Control = Control_L Control_R"
+xmodmap -e "add Mod4 = Super_L Super_R"
+}
+
+
+if xinput --list --name-only | grep -q "CM Storm"; then
+    echo 'Swapping Control and Windows/Super keys'
+    swapctrl
+else
+    echo 'Restoring Control and Windows/Super keys'
+    unswapctrl
+fi
+exit 0