layout-switcher-package/layout-switcher

60 lines
3.1 KiB
Plaintext
Raw Normal View History

2022-09-07 03:40:56 +00:00
#! /bin/bash
data=/usr/share/tromjaro-layout-switcher
icons=$data/icons
profiles=$data/profiles
2022-09-27 22:10:11 +00:00
2022-09-07 03:40:56 +00:00
enable-top-bar-integration() {
# Enable global menus
pacman -Qq vala-panel-appmenu-registrar ||
zensu SKIP_AUTOSNAP= pacman -S --noconfirm vala-panel-appmenu-registrar ||
{ notify-send 'Error' 'Failed installing vala-panel-appmenu-registrar !\nmake sure that you typed the password correctly or that you are not currently installing or updating your system\nEnabling the internet connection might solve the issue'; exit; }
pacman -Qq vala-panel-appmenu-registrar || exit
2022-09-07 03:40:56 +00:00
# Hide window borders when maximized
2022-09-27 14:25:05 +00:00
xfconf-query -c xfwm4 -p /general/borderless_maximize -n -t bool -s true
2022-09-07 03:40:56 +00:00
# Hide top bar of windows when maximized
2022-09-27 14:25:05 +00:00
xfconf-query -c xfwm4 -p /general/titleless_maximize -n -t bool -s true
2022-09-07 03:40:56 +00:00
# Put window buttons on left side
2022-09-27 14:25:05 +00:00
xfconf-query -c xfwm4 -p /general/button_layout -n -t string -s "CMH|"
2022-09-07 03:40:56 +00:00
}
2022-09-27 22:10:11 +00:00
2022-09-07 03:40:56 +00:00
disable-top-bar-integration() {
# Disable global menus
! pacman -Qq vala-panel-appmenu-registrar ||
zensu SKIP_AUTOSNAP= pacman -R --noconfirm vala-panel-appmenu-registrar ||
{ notify-send 'Error' 'Failed removing vala-panel-appmenu-registrar !\nmake sure that you typed the password correctly or that you are not currently installing or updating your system'; exit; }
pacman -Qq vala-panel-appmenu-registrar && exit
2022-09-27 14:25:05 +00:00
killall appmenu-registrar
2022-09-07 03:40:56 +00:00
# Hide window borders when maximized
2022-09-27 14:25:05 +00:00
xfconf-query -c xfwm4 -p /general/borderless_maximize -n -t bool -s true
2022-09-07 03:40:56 +00:00
# Don't hide top bar of windows when maximized
2022-09-27 14:25:05 +00:00
xfconf-query -c xfwm4 -p /general/titleless_maximize -n -t bool -s false
2022-09-07 03:40:56 +00:00
# Put window buttons on right side
2022-09-27 14:25:05 +00:00
xfconf-query -c xfwm4 -p /general/button_layout -n -t string -s "|HMC"
2022-09-07 03:40:56 +00:00
}
2022-09-27 22:10:11 +00:00
2022-09-07 03:40:56 +00:00
choice=$(
2023-08-08 15:41:24 +00:00
yad --no-buttons --center --keep-icon-size --separator='' --use-interp --title 'TROMjaro Layout Switcher' --text-align=center --text ' Please use the Panel Profiles to save your current configuration in case you did any manual changes, else you may lose them.
Changing to or from any layout that has global menus, will require your admin password.' --form --columns 3 \
2023-08-02 01:30:41 +00:00
--field=!"$icons/windows.png"!'Windows-Like (default)':BTN "kill -USR1 \$YAD_PID; echo -n 'Windows-Like'" \
2023-08-06 16:45:34 +00:00
--field=!"$icons/macos.png"!'MacOS-Like (experimental)':BTN "kill -USR1 \$YAD_PID; echo -n 'MacOS-Like'" \
2022-09-07 03:40:56 +00:00
--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'" \
2023-08-06 16:45:34 +00:00
--field=!"$icons/unity.png"!'Unity-Like (experimental)':BTN "kill -USR1 \$YAD_PID; echo -n 'Unity-Like'" \
2022-09-07 03:40:56 +00:00
--field=!"$icons/topx.png"!'TopX-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'TopX-Like'"
)
2022-09-27 22:10:11 +00:00
2022-09-07 03:40:56 +00:00
case "$choice" in
2022-09-27 22:22:06 +00:00
'Windows-Like'|'MX-Like'|'Gnome-Like'|'TopX-Like')
2022-09-27 22:10:11 +00:00
disable-top-bar-integration ;;
2022-09-27 22:22:06 +00:00
'Unity-Like'|'MacOS-Like')
2022-09-27 22:10:11 +00:00
enable-top-bar-integration ;;
2022-09-07 03:40:56 +00:00
*) exit ;;
esac
2022-09-27 22:10:11 +00:00
# Apply the XFCE panel profiles for the chosen layout
xfce4-panel-profiles load "$profiles/$choice.tar.bz2"
killall mate-hud && setsid -f /usr/lib/mate-hud/mate-hud
2022-09-27 22:10:11 +00:00
2023-08-08 15:41:24 +00:00
sleep 2.5 && notify-send "$choice layout was enabled"