1
0
mirror of https://gitlab.com/dbrw/ansible-setup.git synced 2025-08-04 18:25:40 +07:00
ansible-setup/roles/common/files/user_home/.local/bin/keyboard-udev
2022-06-29 17:19:22 +07:00

29 lines
736 B
Bash
Executable File

#!/usr/bin/bash
### WARNING: Your distro might not put bash in this location.
### You could just use `/usr/bin/env bash` instead.
# only needed for debugging
exec >/tmp/udev.out 2>&1
HOME=/home/dim
XAUTHORITY=$HOME/.Xauthority
export XAUTHORITY HOME
DISPLAY=:0 ; export DISPLAY;
# Path to lock file
lock="/tmp/keyboard.lock"
# Lock the file (other atomic alternatives would be "ln" or "mkdir")
exec 9>"$lock"
if ! flock -n 9; then
notify-send -t 5000 "Keyboard script is already running."
exit 1
fi
/usr/bin/su dim -c "sleep 3; /usr//bin/xmodmap $HOME/.Xmodmap;" &
notify-send -t 2000 "Xmodmap finished" &
# The lock file will be unlocked when the script ends
echo '' > /tmp/keyboard.lock &
unset DISPLAY