You are not logged in.

#1 2023-10-27 18:29:35

Automath
Member
Registered: 2016-05-16
Posts: 115

Trying to optimize input methods

I want to take my way with input methods like keyboard, selection and in place text editing. For example, you could be ok with the geneticist's caps lock that's forgoten active by hours, but I'm, tired of it, so I made this simple bash timer:

#!/bin/bash
leddev="$(ls /sys/class/leds/input*capslock/brightness)"

function blink_led {
ledstate=$(cat /sys/class/leds/input*\:\:capslock/brightness )
for i in $( seq 1 "$1"); do
ledstate=$(( $ledstate + 1 ))
ledstate=$(( $ledstate % 2))
echo $ledstate  > "$leddev"
sleep $2
done
}

caps_state=$(xset -q|grep Caps|cut -d: -f3|tr -d ' ')

if ! [[ $caps_state == off01 ]]; then
	blink_led 5 1
	blink_led 10 .5
        sleep 2
	caps_state=$(xset -q|grep Caps|cut -d: -f3|tr -d ' ')
	if ! [[ $caps_state == off01 ]]; then
	xdotool key Caps_Lock
	fi
	echo 0 > "$leddev"
fi

And associated it with the caps lock key in desktop hotkeys, so caps lock turns off automagically after 10s (because I'm no geneticist), genial isn't it? But there's a minor trouble here, and it is that my genious blink led function isn't going to work next boot until I give myself again write permissions over the led device. This is minor, well a bit, because blinking helps me know what's happening, but a mayor issue of similar nature that I'm having is accessing console from an outside program to know which key is pressed aka keylogging myself, so I can construct smarter scripts, like scripting a caps that deactivates at the end of the word or correcting placing uppercase at line start.

Surely somebody may tell me that i'm badly adressing the issues (I hope so), but for that I will open a separate thread.

So I know that this issues are related toudev  rules, so how can I set the correct rules for a program to have rights over a file whithout giving myself full access?

Offline

Board footer

Powered by FluxBB