mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 13:22:28 +00:00
cca2660c3b
* increase synergy between scripts * Fix newlines Fix packagers etc * fix an issue with no new line being created * fix formatting Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * fix extra comma Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * change to () Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * change to () Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * change to () Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * change to () Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * remove extra comma Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * remove "please" Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * add support for caps Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * add support for caps Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * add support for caps Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * remove \n and make the default option "N" Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * add an extra quote Co-authored-by: Adam Perkowski <adas1per@protonmail.com> * add extra quotes * fix remaining sn * fix remaining new lines --------- Co-authored-by: nnyyxxxx <nnyyxxxx@users.noreply.github.com> Co-authored-by: Adam Perkowski <adas1per@protonmail.com>
65 lines
1.4 KiB
Bash
Executable File
65 lines
1.4 KiB
Bash
Executable File
#!/bin/sh -e
|
|
|
|
. ../common-script.sh
|
|
|
|
# setleds can be used in all distros
|
|
# This method works by calling a script using systemd service
|
|
|
|
# Create a script to toggle numlock
|
|
|
|
create_file() {
|
|
printf "%b\n" "Creating script..."
|
|
"$ESCALATION_TOOL" tee "/usr/local/bin/numlock" >/dev/null <<'EOF'
|
|
#!/bin/bash
|
|
|
|
for tty in /dev/tty{1..6}
|
|
do
|
|
/usr/bin/setleds -D +num < "$tty";
|
|
done
|
|
EOF
|
|
|
|
"$ESCALATION_TOOL" chmod +x /usr/local/bin/numlock
|
|
}
|
|
|
|
# Create a systemd service to run the script on boot
|
|
create_service() {
|
|
printf "%b\n" "Creating service..."
|
|
"$ESCALATION_TOOL" tee "/etc/systemd/system/numlock.service" >/dev/null <<'EOF'
|
|
[Unit]
|
|
Description=numlock
|
|
|
|
[Service]
|
|
ExecStart=/usr/local/bin/numlock
|
|
StandardInput=tty
|
|
RemainAfterExit=yes
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
}
|
|
|
|
numlockSetup() {
|
|
# Check if the script and service files exists
|
|
if [ ! -f "/usr/local/bin/numlock" ]; then
|
|
create_file
|
|
fi
|
|
|
|
if [ ! -f "/etc/systemd/system/numlock.service" ]; then
|
|
create_service
|
|
fi
|
|
|
|
printf "%b" "Do you want to enable Numlock on boot? (y/N): "
|
|
read -r confirm
|
|
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
|
|
"$ESCALATION_TOOL" systemctl enable numlock.service --quiet
|
|
printf "%b\n" "Numlock will be enabled on boot"
|
|
else
|
|
"$ESCALATION_TOOL" systemctl disable numlock.service --quiet
|
|
printf "%b\n" "Numlock will not be enabled on boot"
|
|
fi
|
|
}
|
|
|
|
checkEnv
|
|
checkEscalationTool
|
|
numlockSetup
|