feat: add keyboard shortcuts status check and update status script

This commit is contained in:
Menno van Leeuwen 2024-08-22 22:54:25 +02:00
parent 65dc9155bc
commit db2beac40c
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
2 changed files with 29 additions and 0 deletions

View File

@ -4,6 +4,8 @@ source ~/dotfiles/bin/helpers/functions.sh
source ~/dotfiles/bin/helpers/apt_packages.sh source ~/dotfiles/bin/helpers/apt_packages.sh
source ~/dotfiles/bin/helpers/vscode-extensions.sh source ~/dotfiles/bin/helpers/vscode-extensions.sh
source ~/dotfiles/bin/helpers/cargo_packages.sh source ~/dotfiles/bin/helpers/cargo_packages.sh
source ~/dotfiles/bin/helpers/flatpak_packages.sh
source ~/dotfiles/bin/helpers/keyboard_shortcuts.sh
# Check if parameter --verbose was passed # Check if parameter --verbose was passed
if [ "$2" = "--verbose" ]; then if [ "$2" = "--verbose" ]; then
@ -12,6 +14,10 @@ else
verbose=false verbose=false
fi fi
echo -e "\n"
print_keyboard_shortcuts_status
print_apt_status print_apt_status
print_cargo_status print_cargo_status
print_flatpak_status
print_vsc_status print_vsc_status

View File

@ -45,3 +45,26 @@ ensure_keyboard_shortcuts() {
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "${new_bindings_string}" gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "${new_bindings_string}"
} }
print_keyboard_shortcuts_status() {
printfe "%s" "cyan" "Checking keyboard shortcuts..."
echo -en "\r"
# Retrieve current custom keybindings
existing_bindings=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings | tr -d "[]'")
existing_count=$(echo $existing_bindings | tr -cd , | wc -c)
# Iterate over parsed JSON shortcuts
for key_combination in $(echo "$shortcuts" | jq -r 'keys[]'); do
command=$(echo "$shortcuts" | jq -r ".[\"$key_combination\"]")
if [[ ! $existing_bindings =~ "custom${index}" ]]; then
printfe "%s\n" "red" " - Custom shortcut ${key_combination} is missing"
fi
((index++))
done
json_count=$(echo $shortcuts | jq 'keys | length')
printfe "%s\n" "cyan" "Keyboard shortcuts $index/$json_count configured"
}