Created
March 10, 2024 07:13
-
-
Save mahdizojaji/9c37b5557491ee62e1d7dcdbd2468ea0 to your computer and use it in GitHub Desktop.
Disable specific keyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env xdg-open | |
[Desktop Entry] | |
Version=1.0 | |
Type=Application | |
Name=Clavier ON-OFF | |
Exec=bash disable-keyborad.sh | |
Path=/home/mahdi/Music/ | |
NoDisplay=false | |
Categories=Utility; | |
StartupNotify=false | |
Terminal=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
Icon="/PATH/TO/ICON_ON" | |
Icoff="/PATH_TO_ICON_OFF" | |
fconfig=".keyboard" | |
id=$(xinput --list | grep "AT Translated Set 2 keyboard" | awk -F '=' '{print $2}' | awk '{print $1}') | |
echo "$id" | |
if [ ! -f $fconfig ]; then | |
echo "Creating config file" | |
echo "enabled" > $fconfig | |
var="enabled" | |
else | |
read -r var< $fconfig | |
echo "keyboard is : $var" | |
fi | |
if [ "$var" = "disabled" ]; then | |
notify-send -i $Icon "Enabling keyboard..." \ "ON - Keyboard connected !"; | |
echo "enable keyboard..." | |
xinput enable $id | |
echo "enabled" > $fconfig | |
elif [ "$var" = "enabled" ]; then | |
notify-send -i $Icoff "Disabling Keyboard" \ "OFF - Keyboard disconnected"; | |
echo "disable keyboard" | |
xinput disable $id | |
echo 'disabled' > $fconfig | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment