From e1a30d944b4442088fdff5377cba27f12fcf9995 Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Sat, 17 Aug 2024 15:01:05 +0530 Subject: [PATCH 1/2] Add numlock toggle --- src/commands/utils/numlock.sh | 60 +++++++++++++++++++++++++++++++++++ src/tabs.rs | 6 +++- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100755 src/commands/utils/numlock.sh diff --git a/src/commands/utils/numlock.sh b/src/commands/utils/numlock.sh new file mode 100755 index 00000000..b1ac782a --- /dev/null +++ b/src/commands/utils/numlock.sh @@ -0,0 +1,60 @@ +#!/bin/sh -e + +# 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() { + echo "Creating script..." + sudo 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 + + sudo chmod +x /usr/local/bin/numlock +} + +# Create a systemd service to run the script on boot +create_service() { + echo "Creating service..." + sudo 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 +} + +main() { + # 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 "Do you want to enable Numlock on boot? (y/n): " + read -r confirm + if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then + sudo systemctl enable numlock.service --quiet + echo "Numlock will be enabled on boot" + else + sudo systemctl disable numlock.service --quiet + echo "Numlock will not be enabled on boot" + + fi +} + +main diff --git a/src/tabs.rs b/src/tabs.rs index fa4ce3dd..fc650d16 100644 --- a/src/tabs.rs +++ b/src/tabs.rs @@ -54,7 +54,7 @@ pub static TABS: LazyLock> = LazyLock::new(|| { }, ListNode { name: "Remove Snaps", - command: Command::LocalFile("system-setup/4-remove-snaps.sh"), + command: Command::LocalFile("system-setup/5-remove-snaps.sh"), } }), }, @@ -120,6 +120,10 @@ pub static TABS: LazyLock> = LazyLock::new(|| { name: "Bluetooth Manager", command: Command::LocalFile("utils/bluetooth-control.sh"), }, + ListNode { + name: "Toggle Numlock On Startup", + command: Command::LocalFile("utils/numlock.sh"), + }, ListNode { name: "MonitorControl(xorg)", command: Command::None, From f54294cbe0cf4c9eb3b03f6d65bf3f99983d9603 Mon Sep 17 00:00:00 2001 From: JEEVITHA KANNAN K S Date: Wed, 21 Aug 2024 11:56:59 +0530 Subject: [PATCH 2/2] Added numlock to tab_data --- src/commands/utils/tab_data.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/commands/utils/tab_data.toml b/src/commands/utils/tab_data.toml index 41490334..2e5e1283 100644 --- a/src/commands/utils/tab_data.toml +++ b/src/commands/utils/tab_data.toml @@ -8,6 +8,10 @@ script = "wifi-control.sh" name = "Bluetooth Manager" script = "bluetooth-control.sh" +[[data]] +name = "Numlock on Startup" +script = "numlock.sh" + [[data]] name = "Monitor Control"