reduce repetition (hope it works)

This commit is contained in:
Mylloon 2024-05-13 13:46:07 +02:00
parent 53f9bb0543
commit 151ff3dbf8
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

74
arch.sh
View file

@ -13,8 +13,10 @@ cd "$(dirname "$0")" # change script directory
function main { function main {
# === Variables == # === Variables ==
local repo local repo gs_mediakey shortcut
repo=https://git.mylloon.fr/Anri/confOS/raw/branch/main repo=https://git.mylloon.fr/Anri/confOS/raw/branch/main
gs_mediakey=org.gnome.settings-daemon.plugins.media-keys
shortcut=/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings
# === Assure that keyring is installed == # === Assure that keyring is installed ==
@ -105,17 +107,17 @@ function main {
# Change keybindings # Change keybindings
gsettings set org.gnome.shell.keybindings show-screenshot-ui "[]" gsettings set org.gnome.shell.keybindings show-screenshot-ui "[]"
local custom_keybindings_list local custom_keybindings_list
custom_keybindings_list=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings) custom_keybindings_list=$(gsettings get ${gs_mediakey} custom-keybindings)
if [[ $custom_keybindings_list == "@as []" ]] # creating new list if not exists if [[ $custom_keybindings_list == "@as []" ]] # creating new list if not exists
then then
custom_keybindings_list="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/']" custom_keybindings_list="['${shortcut}/flameshot-shortcut/']"
else # if already existing, adding our new element else # if already existing, adding our new element
custom_keybindings_list="${custom_keybindings_list::-1}, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/']" custom_keybindings_list="${custom_keybindings_list::-1}, '${shortcut}/flameshot-shortcut/']"
fi fi
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$custom_keybindings_list" gsettings set ${gs_mediakey} custom-keybindings "$custom_keybindings_list"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/ name "Flameshot" # set name gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/flameshot-shortcut/ name "Flameshot" # set name
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/ command "flameshot gui" # set command gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/flameshot-shortcut/ command "flameshot gui" # set command
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/ binding "Print" # set key gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/flameshot-shortcut/ binding "Print" # set key
# === Emoji picker == # === Emoji picker ==
@ -123,20 +125,20 @@ function main {
rm "$HOME"/.config/gazatu.xyz/emoji-picker.ini 2>/dev/null ||: rm "$HOME"/.config/gazatu.xyz/emoji-picker.ini 2>/dev/null ||:
wget -q --show-progress ${repo}/.config/gazatu.xyz/emoji-picker.ini -P "$HOME"/.config/gazatu.xyz/ wget -q --show-progress ${repo}/.config/gazatu.xyz/emoji-picker.ini -P "$HOME"/.config/gazatu.xyz/
# Add keybinding # Add keybinding
custom_keybindings_list=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings) custom_keybindings_list=$(gsettings get ${gs_mediakey} custom-keybindings)
if ! echo "$custom_keybindings_list" | grep -q "x11-emoji-picker" if ! echo "$custom_keybindings_list" | grep -q "x11-emoji-picker"
then then
if [ "$custom_keybindings_list" = "@as []" ] # creating new list if not exists if [ "$custom_keybindings_list" = "@as []" ] # creating new list if not exists
then then
custom_keybindings_list="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/']" custom_keybindings_list="['${shortcut}/x11-emoji-picker/']"
else # if already existing, adding our new element else # if already existing, adding our new element
custom_keybindings_list=$(echo "$custom_keybindings_list" | sed "s/\[//" | sed "s/\]//") custom_keybindings_list=$(echo "$custom_keybindings_list" | sed "s/\[//" | sed "s/\]//")
custom_keybindings_list="[$custom_keybindings_list, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/']" custom_keybindings_list="[$custom_keybindings_list, '${shortcut}/x11-emoji-picker/']"
fi fi
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$custom_keybindings_list" # update the list gsettings set ${gs_mediakey} custom-keybindings "$custom_keybindings_list" # update the list
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/ name "Emoji-Picker" # set name gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/x11-emoji-picker/ name "Emoji-Picker" # set name
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/ command "emoji-picker" # set command gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/x11-emoji-picker/ command "emoji-picker" # set command
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/ binding "<Super>period" # set shortcut gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/x11-emoji-picker/ binding "<Super>period" # set shortcut
fi fi
@ -169,17 +171,17 @@ function main {
gnome-extensions enable color-picker@tuberry gnome-extensions enable color-picker@tuberry
# Nautilus keybinding # Nautilus keybinding
custom_keybindings_list=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings) custom_keybindings_list=$(gsettings get ${gs_mediakey} custom-keybindings)
if [[ $custom_keybindings_list == "@as []" ]] # creating new list if not exists if [[ $custom_keybindings_list == "@as []" ]] # creating new list if not exists
then then
custom_keybindings_list="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/']" custom_keybindings_list="['${shortcut}/nautilus-shortcut/']"
else # if already existing, adding our new element else # if already existing, adding our new element
custom_keybindings_list="${custom_keybindings_list::-1}, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/']" custom_keybindings_list="${custom_keybindings_list::-1}, '${shortcut}/nautilus-shortcut/']"
fi fi
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$custom_keybindings_list" # updating the list gsettings set ${gs_mediakey} custom-keybindings "$custom_keybindings_list" # updating the list
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/ name "Nautilus" # set name gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/nautilus-shortcut/ name "Nautilus" # set name
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/ command "nautilus -w" # set command gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/nautilus-shortcut/ command "nautilus -w" # set command
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/ binding "<Super>E" # set shortcut gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/nautilus-shortcut/ binding "<Super>E" # set shortcut
# Some Gnome configuration # Some Gnome configuration
gsettings set org.gnome.shell.extensions.dash-to-dock click-action minimize # add minimized window on dock click gsettings set org.gnome.shell.extensions.dash-to-dock click-action minimize # add minimized window on dock click
@ -248,17 +250,17 @@ function main {
# === Clipboard manager == # === Clipboard manager ==
gsettings set org.gnome.shell.keybindings toggle-message-tray "[]" gsettings set org.gnome.shell.keybindings toggle-message-tray "[]"
custom_keybindings_list=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings) custom_keybindings_list=$(gsettings get ${gs_mediakey} custom-keybindings)
if [[ $custom_keybindings_list == "@as []" ]] # creating new list if not exists if [[ $custom_keybindings_list == "@as []" ]] # creating new list if not exists
then then
custom_keybindings_list="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/']" custom_keybindings_list="['${shortcut}/clipboard-shortcut/']"
else # if already existing, adding our new element else # if already existing, adding our new element
custom_keybindings_list="${custom_keybindings_list::-1}, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/']" custom_keybindings_list="${custom_keybindings_list::-1}, '${shortcut}/clipboard-shortcut/']"
fi fi
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$custom_keybindings_list" # updating the list gsettings set ${gs_mediakey} custom-keybindings "$custom_keybindings_list" # updating the list
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/ name "Copyq" # set name gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/clipboard-shortcut/ name "Copyq" # set name
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/ command "copyq show" # set command gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/clipboard-shortcut/ command "copyq show" # set command
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/ binding "<Super>V" # set shortcut gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/clipboard-shortcut/ binding "<Super>V" # set shortcut
copyq > /dev/null & disown copyq > /dev/null & disown
copyq config autostart true copyq config autostart true
echo "style_main_window=true" >> /usr/share/copyq/themes/dark.ini echo "style_main_window=true" >> /usr/share/copyq/themes/dark.ini
@ -365,20 +367,20 @@ function main {
# Enable # Enable
systemctl enable --now --user gpu-screen-recorder systemctl enable --now --user gpu-screen-recorder
# Keybind # Keybind
custom_keybindings_list=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings) custom_keybindings_list=$(gsettings get ${gs_mediakey} custom-keybindings)
if ! echo "$custom_keybindings_list" | grep -q "gpu-screen-recorder" if ! echo "$custom_keybindings_list" | grep -q "gpu-screen-recorder"
then then
if [ "$custom_keybindings_list" = "@as []" ] # creating new list if not exists if [ "$custom_keybindings_list" = "@as []" ] # creating new list if not exists
then then
custom_keybindings_list="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/gpu-screen-recorder/']" custom_keybindings_list="['${shortcut}/gpu-screen-recorder/']"
else # if already existing, adding our new element else # if already existing, adding our new element
custom_keybindings_list=$(echo "$custom_keybindings_list" | sed "s/\[//" | sed "s/\]//") custom_keybindings_list=$(echo "$custom_keybindings_list" | sed "s/\[//" | sed "s/\]//")
custom_keybindings_list="[$custom_keybindings_list, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/gpu-screen-recorder/']" custom_keybindings_list="[$custom_keybindings_list, '${shortcut}/gpu-screen-recorder/']"
fi fi
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$custom_keybindings_list" # update the list gsettings set ${gs_mediakey} custom-keybindings "$custom_keybindings_list" # update the list
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/gpu-screen-recorder/ name "Shadowplay" # set name gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/gpu-screen-recorder/ name "Shadowplay" # set name
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/gpu-screen-recorder/ command "bash -c \"killall -SIGUSR1 gpu-screen-recorder && notify-send -et 3000 -- 'Shadowplay' '2 dernières minutes sauvés dans ~/Vidéos'\"" # set command gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/gpu-screen-recorder/ command "bash -c \"killall -SIGUSR1 gpu-screen-recorder && notify-send -et 3000 -- 'Shadowplay' '2 dernières minutes sauvés dans ~/Vidéos'\"" # set command
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/gpu-screen-recorder/ binding "<Super>Print" # set shortcut gsettings set ${gs_mediakey}.custom-keybinding:${shortcut}/gpu-screen-recorder/ binding "<Super>Print" # set shortcut
fi fi