Fix: xremap switching script

This commit is contained in:
Akemi Izuko 2023-01-08 15:57:38 -07:00
parent 6a3f9a9d08
commit 217ac2ac65
No known key found for this signature in database
GPG key ID: 905D444F6A5E4BE4
2 changed files with 21 additions and 6 deletions

View file

@ -44,22 +44,20 @@ if ! command -v xremap &>/dev/null; then
exit 1 exit 1
fi fi
case "$(echo "$1" | awk '{print tolower($0)}')" in declare path sw_type="$1"
case "$(echo "$sw_type" | awk '{print tolower($0)}')" in
console) console)
ln -sf ~/.config/xremap/config_console.yml ~/.config/xremap/config.yml ln -sf ~/.config/xremap/config_console.yml ~/.config/xremap/config.yml
echo "Switching to minimal console remapping"
;; ;;
mac) mac)
ln -sf ~/.config/xremap/config_mac.yml ~/.config/xremap/config.yml ln -sf ~/.config/xremap/config_mac.yml ~/.config/xremap/config.yml
echo "Switching to mac layout :: ALT | SUPER | SPACE"
;; ;;
pc | standard) pc | standard)
ln -sf ~/.config/xremap/config_standard.yml ~/.config/xremap/config.yml ln -sf ~/.config/xremap/config_standard.yml ~/.config/xremap/config.yml
echo "Switching to standard layout :: SUPER | ALT | SPACE"
;; ;;
fn | small | mini) fn | small | mini)
ln -sf ~/.config/xremap/config_no_fn.yml ~/.config/xremap/config.yml 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 if [[ -n "$1" ]]; then
@ -69,5 +67,22 @@ case "$(echo "$1" | awk '{print tolower($0)}')" in
;; ;;
esac 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 sudo /usr/bin/systemctl restart xremap.service
sleep 2 sleep 2

View file

@ -213,7 +213,7 @@ check_xremap_sudoer() {
if ! sudo -l | grep -Eq 'NOPASSWD:[[:space:]]+/usr/bin/systemctl restart xremap.service'; then if ! sudo -l | grep -Eq 'NOPASSWD:[[:space:]]+/usr/bin/systemctl restart xremap.service'; then
printf "ERR: xremap.service not passwordless for sudoers\n" 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 return_code=1
fi fi