feat: add logging to inserting shortcuts into swhkd
This commit is contained in:
@ -19,18 +19,19 @@ shortcuts=$(jq -r '.shortcuts' "${shortcuts_file}")
|
|||||||
|
|
||||||
ensure_swhkd() {
|
ensure_swhkd() {
|
||||||
shortcuts_keys=($(cat "$DOTFILES_CONFIG" | shyaml keys config.keybinds))
|
shortcuts_keys=($(cat "$DOTFILES_CONFIG" | shyaml keys config.keybinds))
|
||||||
|
file_contents=""
|
||||||
for key in "${shortcuts_keys[@]}"; do
|
for key in "${shortcuts_keys[@]}"; do
|
||||||
shortcut=$(cat "$DOTFILES_CONFIG" | shyaml get-value config.keybinds.$key.shortcut)
|
shortcut=$(cat "$DOTFILES_CONFIG" | shyaml get-value config.keybinds.$key.shortcut)
|
||||||
command=$(cat "$DOTFILES_CONFIG" | shyaml get-value config.keybinds.$key.command)
|
command=$(cat "$DOTFILES_CONFIG" | shyaml get-value config.keybinds.$key.command)
|
||||||
echo "$shortcut"
|
file_contents="${file_contents}\n${shortcut}\n ${command}\n\n"
|
||||||
echo " $command"
|
printfe "%s\n" "green" " - Ensuring swhkd shortcut ${shortcut} command ${command}"
|
||||||
echo
|
|
||||||
done
|
done
|
||||||
|
echo -e "${file_contents}" > $HOME/.config/swhkdrc
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_keyboard_shortcuts() {
|
ensure_keyboard_shortcuts() {
|
||||||
printfe "%s\n" "green" " - Setting up swhkd configuration..."
|
printfe "%s\n" "green" " - Setting up swhkd configuration..."
|
||||||
ensure_swhkd > $HOME/.config/swhkdrc
|
ensure_swhkd
|
||||||
|
|
||||||
# If swhkd is running, kill it
|
# If swhkd is running, kill it
|
||||||
if pgrep -x "swhkd" > /dev/null; then
|
if pgrep -x "swhkd" > /dev/null; then
|
||||||
@ -49,6 +50,12 @@ ensure_keyboard_shortcuts() {
|
|||||||
printfe "%s\n" "yellow" " Note: this will likely show a password prompt, please enter your password"
|
printfe "%s\n" "yellow" " Note: this will likely show a password prompt, please enter your password"
|
||||||
dotf hotkey-daemon &> /dev/null
|
dotf hotkey-daemon &> /dev/null
|
||||||
|
|
||||||
|
# Check if this is gnome DESKTOP_SESSION is gnome, if not we can stop here
|
||||||
|
# The next part is just for setting up custom shortcuts in GNOME
|
||||||
|
if [ "$XDG_CURRENT_DESKTOP" != "GNOME" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
# Retrieve current custom keybindings
|
# Retrieve current custom keybindings
|
||||||
existing_bindings=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings | tr -d "[]'")
|
existing_bindings=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings | tr -d "[]'")
|
||||||
new_bindings=()
|
new_bindings=()
|
||||||
@ -58,7 +65,7 @@ ensure_keyboard_shortcuts() {
|
|||||||
for key_combination in $(echo "$shortcuts" | jq -r 'keys[]'); do
|
for key_combination in $(echo "$shortcuts" | jq -r 'keys[]'); do
|
||||||
command=$(echo "$shortcuts" | jq -r ".[\"$key_combination\"]")
|
command=$(echo "$shortcuts" | jq -r ".[\"$key_combination\"]")
|
||||||
|
|
||||||
printfe '%s\n' "green" " - Ensuring custom shortcut ${key_combination} command ${command}"
|
printfe '%s\n' "green" " - Ensuring GNOME shortcut ${key_combination} command ${command}"
|
||||||
|
|
||||||
custom_binding="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${index}/"
|
custom_binding="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${index}/"
|
||||||
new_bindings+=("$custom_binding")
|
new_bindings+=("$custom_binding")
|
||||||
|
Reference in New Issue
Block a user