Added Script to map Win key to AltGr key (for SK71/SK64)

This commit is contained in:
q3aql 2020-11-04 17:08:41 +01:00
parent 50e1bc528f
commit a033f3e3cb

31
linux/win-to-altgr_xmodmap.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
######################################
# Script to map Win key to AltGr key #
# #
# Author: q3aql@protonmail.ch #
######################################
# Variables
xmodmap_config_dir=/tmp/.win-altgr
xmodmap_config_file=${xmodmap_config_dir}/super-key.key
# Check dir and create/restore config
mkdir -p ${xmodmap_config_dir}
if [ -f ${xmodmap_config_file} ] ; then
echo "* Restoring original function of Win-Key..."
sleep 2
restore_key=$(cat ${xmodmap_config_file})
xmodmap -e "keycode ${restore_key} = Super_L"
rm -rf ${HOME}/.Xmodmap
rm -rf ${xmodmap_config_file}
echo "* Restored!"
else
echo "* Creating mapping of Win-Key to AltGr-Key..."
sleep 2
win_key_detect=$(xmodmap -pke | grep Super_L | grep keycode | head -1 | cut -d " " -f 2)
echo ${win_key_detect} > ${xmodmap_config_file}
xmodmap -e "keycode ${win_key_detect} = ISO_Level3_Shift"
echo "keycode ${win_key_detect} = ISO_Level3_Shift" > ${HOME}/.Xmodmap
echo "* Created!"
fi