-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortcuts.sh
67 lines (51 loc) · 2.36 KB
/
shortcuts.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
#------------------------------------------------------------------------------#
# This script save the workspace switch keybindings and set a more appropiate #
# keybindings that don´t collide with VS Code shortcuts. #
# #
# Author: Álvaro José Agámez Licha #
# Version: 1.0.0 #
# Last Update: 2024-07-22 #
#------------------------------------------------------------------------------#
app_home_name="$HOME/.window-config"
output_file="$app_home_name/org.gnome.desktop.wm.keybindings.backup"
if [ ! -d "$app_home_name" ]; then
mkdir -p "$app_home_name"
fi
check_and_write() {
local search_text="$1"
local content_to_write="$2"
local filename="$3"
# Check if the search text exists in the file
if ! grep -qF "$search_text" "$filename"; then
echo "$content_to_write" >> "$filename"
fi
}
get_keybindings() {
local key_name="$1"
result=$(gsettings get org.gnome.desktop.wm.keybindings $key_name)
echo $result
}
set_keybindings() {
local key_name="$1"
local key_value="$2"
gsettings set org.gnome.desktop.wm.keybindings "$key_name" "$key_value"
}
# Create the file if it doesn't exist
if [ ! -f "$output_file" ]; then
touch "$output_file"
fi
# GENERATE KEYBINDINGS BACKUP
keybindings=$(get_keybindings "switch-to-workspace-left")
check_and_write "switch-to-workspace-left" "switch-to-workspace-left=$keybindings" "$output_file"
keybindings=$(get_keybindings "switch-to-workspace-right")
check_and_write "switch-to-workspace-right" "switch-to-workspace-right=$keybindings" "$output_file"
keybinding=$(get_keybindings "switch-to-workspace-up")
check_and_write "switch-to-workspace-up" "switch-to-workspace-up=$keybindings" "$output_file"
keybinding=$(get_keybindings "switch-to-workspace-down")
check_and_write "switch-to-workspace-down" "switch-to-workspace-down=$keybindings" "$output_file"
# SET NEW KEYBINDINGS
set_keybindings "switch-to-workspace-left" "['<Super>Page_Up', '<Super><Control>Left']"
set_keybindings "switch-to-workspace-right" "['<Super>Page_Up', '<Super><Control>Right']"
set_keybindings "switch-to-workspace-up" "['']"
set_keybindings "switch-to-workspace-down" "['']"