Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

fix: import_krohnkite script not work for symbolic config file #502

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: add export_krohnkite script
  • Loading branch information
zyf0330 committed May 23, 2024
commit e33be415a84fc7a29aa36769070e875c46036b27
72 changes: 72 additions & 0 deletions contrib/export_krohnkite.sh
Original file line number Diff line number Diff line change
@@ -0,0 1,72 @@
#!/bin/bash

# SPDX-FileCopyrightText: 2021-2022 Mikhail Zolotukhin <[email protected]>
# SPDX-License-Identifier: MIT

main ()
{
# Declare a map of shortcuts keys
declare -A bis_to_kro
bis_to_kro["decrease_master_win_count"]="Krohnkite: Decrease"
bis_to_kro["decrease_window_height"]="Krohnkite: Shrink Height"
bis_to_kro["decrease_window_width"]="Krohnkite: Shrink Width"
bis_to_kro["focus_bottom_window"]="Krohnkite: Down/Next"
bis_to_kro["focus_left_window"]="Krohnkite: Left"
bis_to_kro["focus_right_window"]="Krohnkite: Right"
bis_to_kro["focus_upper_window"]="Krohnkite: Up/Prev"
bis_to_kro["increase_master_win_count"]="Krohnkite: Increase"
bis_to_kro["increase_window_height"]="Krohnkite: Grow Height"
bis_to_kro["increase_window_width"]="Krohnkite: Grow Width"
bis_to_kro["move_window_to_bottom_pos"]="Krohnkite: Move Down/Next"
bis_to_kro["move_window_to_left_pos"]="Krohnkite: Move Left"
bis_to_kro["move_window_to_right_pos"]="Krohnkite: Move Right"
bis_to_kro["move_window_to_upper_pos"]="Krohnkite: Move Up/Prev"
bis_to_kro["next_layout"]="Krohnkite: Next Layout"
bis_to_kro["prev_layout"]="Krohnkite: Previous Layout"
bis_to_kro["push_window_to_master"]="Krohnkite: Set master"
bis_to_kro["rotate"]="Krohnkite: Rotate"
bis_to_kro["rotate_part"]="Krohnkite: Rotate Part"
bis_to_kro["toggle_monocle_layout"]="Krohnkite: Monocle Layout"
bis_to_kro["toggle_quarter_layout"]="Krohnkite: Quarter Layout"
bis_to_kro["toggle_spread_layout"]="Krohnkite: Spread Layout"
bis_to_kro["toggle_stair_layout"]="Krohnkite: Stair Layout"
bis_to_kro["toggle_three_column_layout"]="Krohnkite: Three Column Layout"
bis_to_kro["toggle_tile_layout"]="Krohnkite: Tile Layout"
bis_to_kro["toggle_window_floating"]="Krohnkite: Float"
bis_to_kro["toggle_floating_layout"]="Krohnkite: Float All"

config_file_path=$(realpath ${1:-~/.config/kglobalshortcutsrc})

echo "Config file path: ${config_file_path}"
echo "Importing Krohnkite shortcuts..."

# Iterate over each pair and move the Krohnkite shortcut to Bismuth one
for key in "${!bis_to_kro[@]}"; do
bis_key="${key}"
kro_key=${bis_to_kro[$key]}
bis_val=$(kreadconfig5 --file "${config_file_path}" --group "bismuth" --key "${bis_key}")
kro_val=$(kreadconfig5 --file "${config_file_path}" --group "kwin" --key "${kro_key}")

IFS=',' read -ra bis_val_arr <<< "$bis_val"
IFS=',' read -ra kro_val_arr <<< "$kro_val"

bis_primary_shortcut="${bis_val_arr[0]}"
bis_secondary_shortcut="${bis_val_arr[1]}"
bis_description="${bis_val_arr[2]}"

kro_primary_shortcut="${kro_val_arr[0]}"
kro_secondary_shortcut="${kro_val_arr[1]}"
kro_description="${kro_val_arr[2]}"

kwriteconfig5 --file "${config_file_path}" --group "kwin" --key "${kro_key}" --delete > /dev/null 2>&1
kwriteconfig5 --file "${config_file_path}" --group "bismuth" --key "${bis_key}" "${kro_primary_shortcut:-none},${kro_secondary_shortcut:-none},${bis_description}"

kwriteconfig5 --file "${config_file_path}" --group "bismuth" --key "${bis_key}" --delete > /dev/null 2>&1
kwriteconfig5 --file "${config_file_path}" --group "kwin" --key "${kro_key}" "${bis_primary_shortcut:-none},${bis_secondary_shortcut:-none},${kro_description}"
done

# Reload shortcuts configuration
systemctl --user restart plasma-kglobalaccel
}

main $1