Merge pull request 'Simplify code' (#2) from rokosun-patch-1 into master

Reviewed-on: #2
This commit is contained in:
Tio TROM 2022-09-28 00:33:34 +02:00
commit 5d9229a879

View File

@ -2,6 +2,7 @@
data=/usr/share/tromjaro-layout-switcher data=/usr/share/tromjaro-layout-switcher
icons=$data/icons icons=$data/icons
profiles=$data/profiles profiles=$data/profiles
enable-top-bar-integration() { enable-top-bar-integration() {
# Enable global menus # Enable global menus
pacman -Qq vala-panel-appmenu-registrar || pacman -Qq vala-panel-appmenu-registrar ||
@ -16,6 +17,7 @@ enable-top-bar-integration() {
# Put window buttons on left side # Put window buttons on left side
xfconf-query -c xfwm4 -p /general/button_layout -n -t string -s "CMH|" xfconf-query -c xfwm4 -p /general/button_layout -n -t string -s "CMH|"
} }
disable-top-bar-integration() { disable-top-bar-integration() {
# Disable global menus # Disable global menus
! pacman -Qq vala-panel-appmenu-registrar || ! pacman -Qq vala-panel-appmenu-registrar ||
@ -31,35 +33,26 @@ disable-top-bar-integration() {
# Put window buttons on right side # Put window buttons on right side
xfconf-query -c xfwm4 -p /general/button_layout -n -t string -s "|HMC" xfconf-query -c xfwm4 -p /general/button_layout -n -t string -s "|HMC"
} }
choice=$( choice=$(
yad --no-buttons --center --keep-icon-size --separator='' --use-interp --title 'TROMjaro Layout Switcher' --text-align=center --text 'Changing to or from any layout that has global menus, will require your admin password' --form --columns 3 \ yad --no-buttons --center --keep-icon-size --separator='' --use-interp --title 'TROMjaro Layout Switcher' --text-align=center --text 'Changing to or from any layout that has global menus, will require your admin password' --form --columns 3 \
--field=!"$icons/windows.png"!'Windows-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'Windows-Like'" \ --field=!"$icons/windows.png"!'Windows-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'Windows-Like'" \
--field=!"$icons/macos.png"!'MacOS-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'MacOS-Like'" \ --field=!"$icons/macos.png"!'MacOS-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'MacOS-Like'" \
--field=!"$icons/mx.png"!'MX-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'MX-Like'" \ --field=!"$icons/mx.png"!'MX-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'MX-Like'" \
--field=!"$icons/gnome.png"!'Gnome-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'Gnome-Like'" \ --field=!"$icons/gnome.png"!'Gnome-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'Gnome-Like'" \
--field=!"$icons/unity.png"!'Unity-Like (default)':BTN "kill -USR1 \$YAD_PID; echo -n 'Unity-Like (default)'" \ --field=!"$icons/unity.png"!'Unity-Like (default)':BTN "kill -USR1 \$YAD_PID; echo -n 'Unity-Like'" \
--field=!"$icons/topx.png"!'TopX-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'TopX-Like'" --field=!"$icons/topx.png"!'TopX-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'TopX-Like'"
) )
case "$choice" in case "$choice" in
'Windows-Like') 'Windows-Like'|'MX-Like'|'Gnome-Like'|'TopX-Like')
disable-top-bar-integration disable-top-bar-integration ;;
xfce4-panel-profiles load "$profiles"/Windows-Like.tar.bz2 ;; 'Unity-Like'|'MacOS-Like')
'Unity-Like (default)') enable-top-bar-integration ;;
enable-top-bar-integration
xfce4-panel-profiles load "$profiles"/Unity-Like.tar.bz2 ;;
'MX-Like')
disable-top-bar-integration
xfce4-panel-profiles load "$profiles"/MX-Like.tar.bz2 ;;
'MacOS-Like')
enable-top-bar-integration
xfce4-panel-profiles load "$profiles"/MacOS-Like.tar.bz2 ;;
'Gnome-Like')
disable-top-bar-integration
xfce4-panel-profiles load "$profiles"/Gnome-Like.tar.bz2 ;;
'TopX-Like')
disable-top-bar-integration
xfce4-panel-profiles load "$profiles"/TopX-Like.tar.bz2 ;;
*) exit ;; *) exit ;;
esac esac
# Apply the XFCE panel profiles for the chosen layout
xfce4-panel-profiles load "$profiles/$choice.tar.bz2"
sleep 2.5 && notify-send "$choice layout was enabled" sleep 2.5 && notify-send "$choice layout was enabled"