Skip to content

Commit c031409

Browse files
authored
Remove sudo from keyboard commands (#159)
* Update README, remove sudo from keymap.tcl and virtual-programs * Add forloop for usermods, avoids errors when certain groups don't exist * Remove extranous usermod instruction * Fix esc-restart, remove sudo from keymap Instead of using `loadkeys` we're now using `kbd_mode -u` to load the keymap. This is because `loadkeys` requires root permissions and we're trying to remove the need for `sudo` in the system. I tried removing `sudo` from the `esc-restart` virtual program but it failed with an interactive authentication error. I'm not sure how to do this with less powerful permissions than `sudo` so I'm leaving it as is for now. * Add kdb to explicit dependnecies to get around need for loadkeys This is precautionary, in practice kbd is a dependency of console-data but I could image cases in the future where we swap console-data but still need kdb.
1 parent dfd24a5 commit c031409

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ if flashing from a Mac])
6161
If no `folk` user, then:
6262

6363
sudo useradd -m folk; sudo passwd folk;
64-
sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,render,netdev,lpadmin,gpio,i2c,spi folk
65-
66-
(If you get errors from usermod like `group 'gpio' does not exist`,
67-
try running again omitting the groups that don't exist from the
68-
command.)
64+
for group in adm dialout cdrom sudo audio video plugdev games users input tty render netdev lpadmin gpio i2c spi; do sudo usermod -a -G $group folk; done; groups folk
6965

7066
1. `sudo apt update`
7167

@@ -79,7 +75,7 @@ if flashing from a Mac])
7975
1. Install dependencies: `sudo apt install rsync tcl-thread tcl8.6-dev
8076
git libjpeg-dev libpng-dev fbset libdrm-dev pkg-config v4l-utils
8177
mesa-vulkan-drivers vulkan-tools libvulkan-dev libvulkan1 meson
82-
libgbm-dev glslc vulkan-validationlayers console-data`
78+
libgbm-dev glslc vulkan-validationlayers console-data kbd`
8379

8480
(When prompted while installing `console-data` for `Policy for handling keymaps` type `3` (meaning `3. Keep kernel keymap`) and press `Enter`)
8581

lib/keymap.tcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ namespace eval keymap {
157157
}
158158

159159
proc load {name} {
160-
exec sudo loadkeys $name
161-
set keytable [exec sudo dumpkeys -kf]
162-
set unitable [exec sudo dumpkeys -kfn]
160+
exec kbd_mode -u $name
161+
set keytable [exec dumpkeys -kf]
162+
set unitable [exec dumpkeys -kfn]
163163

164164
set ksyms [dict create]
165165
set mods [_fillRange 0-15]

virtual-programs/esc-restart.folk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
When keyboard /k/ claims key Meta_Escape is down with timestamp /any/ {
2+
# When sudo is removed here you get:
3+
#
4+
# Error in virtual-programs/esc-restart.folk, match m10029:6: Failed to restart folk.service: Interactive authentication required.
5+
#
6+
# TODO: Figure out how to do this with less powerful permissions than `sudo`.
27
exec sudo systemctl restart folk
38
}

virtual-programs/keyboard.folk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ proc walkInputEventPaths {} {
2525
if {[file readable $device] == 0} {
2626
puts "Device $device is not readable. Attempting to change permissions."
2727
# Attempt to change permissions so that the file can be read
28-
exec sudo chmod +r $device
28+
exec chmod +r $device
2929
}
3030
lappend keyboards $device
3131
}

0 commit comments

Comments
 (0)