blob: 5357909aa63a601fd77023b2d4a2306b6326e388 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/bin/sh
# File: /usr/local/bin/kvm-plugged-in.sh
# Location: vm2
# Author: bgstack15
# Startdate: 2023-01-11-4 14:32
# Title: Script that runs in user context when kvm is plugged in
# Project: kvm-mapping
# Purpose: for vm2, run my keyboard input script.
# History:
# 2023-08-04 updated regex to include Logitech K, and a short sleep for it
# Usage:
# called by kvm-user-daemon.sh when the trigger file is made by the udev rule+script
# Reference:
# https://unix.stackexchange.com/questions/71348/why-doesnt-this-udev-rule-trigger-upon-removal-of-the-device
# Improve:
# Dependencies:
# xinput and setxkbmap
# running in user context, with XAUTHORITY and DISPLAY and probably more env vars
# Documentation:
# The contents can be whatever you want. On vm2, I want to set my keyboard mappings.
sleep 2
for word in $( xinput list | sed -r -n -e 's/.*(Keyboard|Logitech K[0-9]+).*id=([0-9]+).*keyboard.*/\2/p;' ) ;
do
setxkbmap -device ${word} -option grp:switch,grp:shifts_toggle -layout 'us,us(dvorak)'
done
#notify-send --transient --icon 'keyboard' 'kvm reconnected' 'applied keymaps'
|