From 8da498a117301ad097be65828d03fa57043ab61a Mon Sep 17 00:00:00 2001
From: tio <tio@trom.tf>
Date: Wed, 7 Sep 2022 05:40:56 +0200
Subject: [PATCH] initial commit

---
 Makefile                         | 12 ++++++
 PKGBUILD                         | 40 ++++++++++++++++++++
 README.md                        | 21 +++++++++++
 layout-switcher                  | 65 ++++++++++++++++++++++++++++++++
 tromjaro-layout-switcher.desktop | 10 +++++
 5 files changed, 148 insertions(+)
 create mode 100644 Makefile
 create mode 100644 PKGBUILD
 create mode 100644 README.md
 create mode 100644 layout-switcher
 create mode 100644 tromjaro-layout-switcher.desktop

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..eabba4d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,12 @@
+# makefile for theme-switcher
+build:
+	makepkg
+
+install:
+	pamac-installer theme-switcher-*.tar.xz
+
+remove:
+	pamac-installer --remove theme-switcher
+
+clean:
+	$(RM) -rf src/ pkg/ *.tar.xz
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 0000000..eee6a84
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,40 @@
+# Maintainer: TROM <contact@tromsite.com>
+pkgname=tromjaro-layout-switcher
+pkgver=1.0.0
+pkgrel=1
+pkgdesc="TROMjaro Layout switcher application"
+arch=(any)
+url=""
+license=(unknown)
+depends=('yad'
+         'xfce4-panel-profiles'
+         'vala-panel-appmenu-registrar-git'
+         'vala-panel-appmenu-xfce'
+         'vala-panel-appmenu-common'
+         'libdbusmenu-gtk2'
+         'appmenu-gtk-module')
+provides=('tromjaro-layout-switcher')
+backup=()
+options=(!strip)
+source=("layout-switcher"
+        "layout-switcher.desktop"
+        "https://www.drive.tromsite.com/s/SWmAcokLcxLB3gM/download"
+        "https://www.drive.tromsite.com/s/6dHoNjar9wJzeLd/download")
+sha256sums=('SKIP'
+'SKIP'
+'SKIP'
+'SKIP')
+package() {
+    # copy icons
+    install -d ${pkgdir}/usr/share/tromjaro-layout-switcher/icons
+    install -Dm644 ${srcdir}/icons/*                            ${pkgdir}/usr/share/tromjaro-layout-switcher/icons
+
+    # copy profiles
+    install -d ${pkgdir}/usr/share/tromjaro-layout-switcher/profiles
+    install -Dm644 ${srcdir}/profiles/*                            ${pkgdir}/usr/share/tromjaro-layout-switcher/profiles
+
+
+    # copy executables
+    install -Dm644  ${srcdir}/tromjaro-layout-switcher.desktop            ${pkgdir}/usr/share/applications/tromjaro-layout-switcher.desktop
+	install -Dm755  ${srcdir}/theme-switcher                    ${pkgdir}/usr/bin/tromjaro-theme-switcher
+}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5cacdd6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,21 @@
+# Theme switcher package
+
+Theme switcher application
+
+## Building the package
+
+Open Terminal and issue the command:
+
+`make`
+
+To install the package right after the building, use:
+
+`make install`
+
+To remove just installed package, use:
+
+`make remove`
+
+To cleanup the project, use:
+
+`make clean`
diff --git a/layout-switcher b/layout-switcher
new file mode 100644
index 0000000..1766cf5
--- /dev/null
+++ b/layout-switcher
@@ -0,0 +1,65 @@
+#! /bin/bash
+data=/usr/share/tromjaro-layout-switcher
+icons=$data/icons
+profiles=$data/profiles
+enable-top-bar-integration() {
+    # Enable global menus
+    pacman -Qq vala-panel-appmenu-registrar-git ||
+        zensu SKIP_AUTOSNAP= pacman -S --noconfirm vala-panel-appmenu-registrar-git ||
+        { notify-send 'Error' 'failed installing vala-panel-appmenu-registrar-git !\nmake sure you type the correct password\nEnabling the internet connection might solve the issue'; exit; }
+    pacman -Qq vala-panel-appmenu-registrar-git || exit
+
+    # Hide window borders when maximized
+    xfconf-query -c xfwm4 -p /general/borderless_maximize -n -t bool -s true &
+    # Hide top bar of windows when maximized
+    xfconf-query -c xfwm4 -p /general/titleless_maximize -n -t bool -s true &
+    # Put window buttons on left side
+    xfconf-query -c xfwm4 -p /general/button_layout -n -t string -s "CMH|" &
+}
+disable-top-bar-integration() {
+    # Disable global menus
+    ! pacman -Qq vala-panel-appmenu-registrar-git ||
+        zensu SKIP_AUTOSNAP= pacman -R --noconfirm vala-panel-appmenu-registrar-git ||
+        { notify-send 'Error' 'failed removing vala-panel-appmenu-registrar-git !\nmake sure you type the correct password'; exit; }
+    pacman -Qq vala-panel-appmenu-registrar-git && exit
+    killall appmenu-registrar &
+
+    # Hide window borders when maximized
+    xfconf-query -c xfwm4 -p /general/borderless_maximize -n -t bool -s true &
+    # Don't hide top bar of windows when maximized
+    xfconf-query -c xfwm4 -p /general/titleless_maximize -n -t bool -s false &
+    # Put window buttons on right side
+    xfconf-query -c xfwm4 -p /general/button_layout -n -t string -s "|HMC" &
+}
+choice=$(
+yad --no-buttons --center --keep-icon-size --separator='' --use-interp --title '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/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/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/topx.png"!'TopX-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'TopX-Like'"
+)
+case "$choice" in
+    'Windows-Like')
+        disable-top-bar-integration
+        xfce4-panel-profiles load "$profiles"/Windows-Like.tar.bz2 & ;;
+    'Unity-Like (default)')
+        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 ;;
+esac
+
+sleep 5 && notify-send "$choice layout was enabled"
\ No newline at end of file
diff --git a/tromjaro-layout-switcher.desktop b/tromjaro-layout-switcher.desktop
new file mode 100644
index 0000000..3eb08a7
--- /dev/null
+++ b/tromjaro-layout-switcher.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=Layout Switcher
+GenericName=Layout Switcher
+Comment=Change how TROMjaro looks like. Make it look like Unity, Windows, Gnome, and so forth.
+Icon=layout-switch
+Exec=tromjaro-layout-switcher
+Categories=DesktopSettings;GTK;Settings;X-XFCE-PersonalSettings;X-XFCE-SettingsDialog;XFCE;
+Keywords=settings;layout;toggle;switch;