From 217ac2ac655025c9fb1150e0804e9d196cc47aed Mon Sep 17 00:00:00 2001 From: Akemi Izuko Date: Sun, 8 Jan 2023 15:57:38 -0700 Subject: [PATCH] Fix: xremap switching script --- bin/switch_keyboards.sh | 25 ++++++++++++++++++++----- post_install.sh | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bin/switch_keyboards.sh b/bin/switch_keyboards.sh index 3a55b28..3e84f35 100755 --- a/bin/switch_keyboards.sh +++ b/bin/switch_keyboards.sh @@ -44,22 +44,20 @@ if ! command -v xremap &>/dev/null; then exit 1 fi -case "$(echo "$1" | awk '{print tolower($0)}')" in +declare path sw_type="$1" + +case "$(echo "$sw_type" | awk '{print tolower($0)}')" in console) ln -sf ~/.config/xremap/config_console.yml ~/.config/xremap/config.yml - echo "Switching to minimal console remapping" ;; mac) ln -sf ~/.config/xremap/config_mac.yml ~/.config/xremap/config.yml - echo "Switching to mac layout :: ALT | SUPER | SPACE" ;; pc | standard) ln -sf ~/.config/xremap/config_standard.yml ~/.config/xremap/config.yml - echo "Switching to standard layout :: SUPER | ALT | SPACE" ;; fn | small | mini) ln -sf ~/.config/xremap/config_no_fn.yml ~/.config/xremap/config.yml - echo "Switching to no-fn row standard layout :: SUPER | ALT | SPACE" ;; *) if [[ -n "$1" ]]; then @@ -69,5 +67,22 @@ case "$(echo "$1" | awk '{print tolower($0)}')" in ;; esac +if path="$(basename "$(realpath ~/.config/xremap/config.yml)")"; then + case "$path" in + config_console.yml) + echo "Using minimal console remapping";; + config_mac.yml) + echo "Using mac layout :: ALT | SUPER | SPACE";; + config_standard.yml) + echo "Using standard layout :: ALT | SUPER | SPACE";; + config_no_fn.yml) + echo "Using standard no-fn row layout :: ALT | SUPER | SPACE";; + *) + echo "Using unidentified layout";; + esac +else + echo "xremap config path not found" +fi + sudo /usr/bin/systemctl restart xremap.service sleep 2 diff --git a/post_install.sh b/post_install.sh index 8c72f26..607f953 100755 --- a/post_install.sh +++ b/post_install.sh @@ -213,7 +213,7 @@ check_xremap_sudoer() { if ! sudo -l | grep -Eq 'NOPASSWD:[[:space:]]+/usr/bin/systemctl restart xremap.service'; then printf "ERR: xremap.service not passwordless for sudoers\n" - printf "\t $ please echo \"%wheel ALL=NOPASSWD: /usr/bin/systemctl restart xremap.service\" >> /etc/sudoers.d/xremap\n" + printf "\t $ please bash -c 'echo \"%s\" >> /etc/sudoers.d/xremap'\n" '%wheel ALL=NOPASSWD: /usr/bin/systemctl restart xremap.service' return_code=1 fi