Compare commits

...

56 Commits

Author SHA1 Message Date
ec806de9bd Update PKGBUILD 2025-01-06 19:14:54 +00:00
85ac25afcc Make layout buttons resizable 2025-01-06 16:14:38 +05:30
3b779b3f67 preserve some configs for layouts 2024-09-11 13:31:52 +00:00
b39718516f fixed whisker searches 2024-09-04 22:25:20 +00:00
72c118a6ee using the vala-panel-appmenu-registrar git version 2024-05-05 12:22:34 +00:00
da7cfce288 using the vala-panel-appmenu-registrar git version 2024-05-05 12:21:50 +00:00
Rokosun
ae83bfbbd6 Update command for installing owlkettle 2024-03-28 17:20:46 +00:00
e270acc3dd remove optdepends=('vala-panel-appmenu-registrar') 2024-03-04 12:06:39 +00:00
1f24cd0bf0 revert d412f8a653
revert removed optdepends=('vala-panel-appmenu-registrar')
2024-03-04 12:00:03 +00:00
d412f8a653 removed optdepends=('vala-panel-appmenu-registrar') 2024-03-01 15:39:35 +00:00
07b1641178 removed vala-panel-appmenu-common-git
the vala-panel-appmenu-xfce-git depends on it anyway
2024-03-01 13:53:09 +00:00
486f650395 Update PKGBUILD 2024-01-06 21:54:31 +00:00
c9a2438c1d bump up the version 2024-01-03 18:21:01 +00:00
rokosun
d43af1f7fd better-manage-global-menu (#4)
Reviewed-on: https://git.trom.tf/TROMjaro/layout-switcher-package/pulls/4
2024-01-01 15:38:54 +00:00
rokosun
666d24625b Remove the 3 second delay 2023-12-26 19:02:06 +00:00
rokosun
2eb10c5b71 Check if thread is running before passing it to joinThread() 2023-12-26 18:48:04 +00:00
rokosun
f2ec92a22d Change delay from 5 seconds to 3 seconds 2023-12-26 05:22:49 +00:00
43c356debb Merge pull request 'Rewrite layout switcher in Nim' (#3) from nim-rewrite into master
Reviewed-on: https://git.trom.tf/TROMjaro/layout-switcher-package/pulls/3
2023-12-26 00:08:42 +00:00
rokosun
1f29b13f85 Show loading animation when changing layouts 2023-12-25 15:23:03 +00:00
rokosun
c020b3626f Add more dependencies 2023-12-25 08:27:04 +00:00
rokosun
ea7d1b8270 Update Makefile 2023-12-25 08:02:42 +00:00
rokosun
b1dc6d7e29 Update PKGBUILD for the new code in Nim 2023-12-25 08:01:59 +00:00
rokosun
779117672e Add polkit action file 2023-12-25 08:00:39 +00:00
rokosun
f56041dffc revert dfc402f767
revert Add polkit action file
2023-12-25 07:59:16 +00:00
rokosun
dfc402f767 Add polkit action file 2023-12-25 07:56:20 +00:00
rokosun
87ae3a63f5 Add toggleGlobalMenu.nim 2023-12-25 07:54:45 +00:00
rokosun
b7578dd97f Add sharedModule.nim 2023-12-25 07:52:09 +00:00
rokosun
c60c17100b Replace bash script with the new code in Nim 2023-12-25 07:50:13 +00:00
1b05faf263 Update PKGBUILD 2023-10-17 00:20:21 +02:00
afa6f761c3 Update PKGBUILD 2023-08-08 17:41:47 +02:00
893b89fc54 changed the description a bit 2023-08-08 17:41:24 +02:00
91c24321ee Update PKGBUILD 2023-08-08 05:02:20 +02:00
038135edb2 Update PKGBUILD 2023-08-08 04:43:23 +02:00
fae8069f87 Update PKGBUILD 2023-08-08 03:53:46 +02:00
6e5ba981be Update PKGBUILD 2023-08-06 23:42:25 +02:00
626c840477 marked unity and macos as experimental 2023-08-06 18:45:34 +02:00
fecf58cfa7 fixed some indicators for the docklike 2023-08-04 14:13:06 +02:00
0fd1a1175e Update PKGBUILD 2023-08-02 21:56:57 +02:00
5e08507e2c fix a bug that made HUD use 100% of the CPU 2023-08-02 21:56:27 +02:00
f059e4e550 removed the recently used apps from whisker 2023-08-02 17:49:39 +02:00
22ce09baa3 improved layouts 2023-08-02 03:31:13 +02:00
af774bfcdc windows-like default 2023-08-02 03:30:41 +02:00
763d1e5188 Update 'PKGBUILD' 2023-02-21 01:45:18 +01:00
1476a98f62 Update 'PKGBUILD' 2023-02-21 01:40:23 +01:00
7ee7641f03 move to "vala-panel-appmenu-registrar" instead of git 2023-02-21 01:30:57 +01:00
4bdf6261ee move to "vala-panel-appmenu-registrar" instead of git 2023-02-21 01:30:27 +01:00
23189891ac fix some vala panel appmenu git issues with the script 2022-11-17 21:45:57 +01:00
c72ab9c6b0 switched to vala appmenu git 2022-11-17 21:45:27 +01:00
8b30300998 change to the git version for vala packages 2022-11-17 16:18:26 +01:00
15e42fb098 Update 'PKGBUILD' 2022-10-08 01:10:35 +02:00
rokosun
539cde3527 It should be "removing" 2022-10-07 21:30:07 +02:00
756ed64555 improved the error messages 2022-10-06 15:01:06 +02:00
8ce554af47 Update 'PKGBUILD' 2022-09-29 19:05:40 +02:00
5d9229a879 Merge pull request 'Simplify code' (#2) from rokosun-patch-1 into master
Reviewed-on: https://git.trom.tf/TROMjaro/layout-switcher-package/pulls/2
2022-09-28 00:33:34 +02:00
rokosun
cb46fe6fcb Fix TopX-Like layout 2022-09-28 00:22:06 +02:00
rokosun
22a7fc4321 Simplify code 2022-09-28 00:10:11 +02:00
8 changed files with 340 additions and 97 deletions

View File

@@ -1,12 +1,12 @@
# makefile for layout-switcher # makefile for layout-switcher
build: build:
makepkg makepkg -s
install: install:
pamac-installer tromjaro-layout-switcher-*.tar.xz pamac-installer tromjaro-layout-switcher-*.tar.zst
remove: remove:
pamac-installer --remove tromjaro-layout-switcher pamac-installer --remove tromjaro-layout-switcher
clean: clean:
$(RM) -rf src/ pkg/ *.tar.xz $(RM) -rf src/ pkg/ icons.zip profiles.zip *.tar.zst

View File

@@ -1,24 +1,33 @@
# Maintainer: TROM <contact@tromsite.com> # Maintainer: TROM <contact@tromsite.com>
pkgname=tromjaro-layout-switcher pkgname=tromjaro-layout-switcher
pkgver=1.2.1 pkgver=2
pkgrel=1 pkgrel=4
pkgdesc="TROMjaro Layout switcher application" pkgdesc="TROMjaro Layout switcher application"
arch=(any) arch=('x86_64')
url="" url="https://git.trom.tf/TROMjaro/layout-switcher-package"
license=(unknown) license=(unknown)
depends=('yad' depends=('xfce4-panel-profiles'
'zensu' 'vala-panel-appmenu-registrar-git'
'xfce4-panel-profiles' 'util-linux'
'vala-panel-appmenu-xfce' 'xfconf'
'vala-panel-appmenu-common' 'polkit'
'mate-hud'
'psmisc'
'pacman'
'coreutils'
'vala-panel-appmenu-xfce-git'
'libdbusmenu-gtk2' 'libdbusmenu-gtk2'
'appmenu-gtk-module') 'appmenu-gtk-module')
optdepends=('vala-panel-appmenu-registrar') makedepends=('choosenim')
provides=('tromjaro-layout-switcher') provides=('tromjaro-layout-switcher')
backup=() backup=()
options=(!strip) options=(!strip)
source=("layout-switcher" source=("layoutSwitcher.nim"
"toggleGlobalMenu.nim"
"sharedModule.nim"
"tromjaro-layout-switcher.desktop" "tromjaro-layout-switcher.desktop"
"com.tromjaro.LayoutSwitcher.policy"
"disable-global-menu.hook"
"tromjaro-layout-switcher.svg" "tromjaro-layout-switcher.svg"
"icons.zip::https://www.drive.tromsite.com/s/SWmAcokLcxLB3gM/download" "icons.zip::https://www.drive.tromsite.com/s/SWmAcokLcxLB3gM/download"
"profiles.zip::https://www.drive.tromsite.com/s/6dHoNjar9wJzeLd/download") "profiles.zip::https://www.drive.tromsite.com/s/6dHoNjar9wJzeLd/download")
@@ -26,23 +35,55 @@ sha256sums=('SKIP'
'SKIP' 'SKIP'
'SKIP' 'SKIP'
'SKIP' 'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP') 'SKIP')
package() { prepare() {
# copy icons # Disable telemetry in choosenim if user is running it for the first time
install -d ${pkgdir}/usr/share/tromjaro-layout-switcher/icons [ -f "$HOME"/.choosenim/analytics ] || {
install -Dm644 ${srcdir}/icons/* ${pkgdir}/usr/share/tromjaro-layout-switcher/icons mkdir -p "$HOME"/.choosenim
touch "$HOME"/.choosenim/analytics
# copy profiles }
install -d ${pkgdir}/usr/share/tromjaro-layout-switcher/profiles echo 'Install Nim if not already installed:'
install -Dm644 ${srcdir}/profiles/* ${pkgdir}/usr/share/tromjaro-layout-switcher/profiles choosenim stable
echo 'Update Nim to the latest stable release:'
choosenim update stable
# copy executables echo 'Refresh nimble package list:'
install -Dm644 ${srcdir}/tromjaro-layout-switcher.desktop ${pkgdir}/usr/share/applications/tromjaro-layout-switcher.desktop "$HOME"/.nimble/bin/nimble --nim:"$HOME"/.nimble/bin/nim refresh
install -Dm755 ${srcdir}/layout-switcher ${pkgdir}/usr/bin/tromjaro-layout-switcher echo 'Install owlkettle from the latest git commit:'
"$HOME"/.nimble/bin/nimble --nim:"$HOME"/.nimble/bin/nim install owlkettle
# copy icon }
install -d ${pkgdir}/usr/share/icons/hicolor/scalable/apps build(){
install -Dm644 ${srcdir}/tromjaro-layout-switcher.svg ${pkgdir}/usr/share/icons/hicolor/scalable/apps echo 'Compile layoutSwitcher.nim for release build:'
"$HOME"/.nimble/bin/nim c -d:release --out:${srcdir}/layoutSwitcher ${srcdir}/layoutSwitcher.nim
echo 'Compile toggleGlobalMenu.nim for release build:'
"$HOME"/.nimble/bin/nim c -d:release --out:${srcdir}/toggleGlobalMenu ${srcdir}/toggleGlobalMenu.nim
}
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 pacman hook file
install -Dm644 ${srcdir}/disable-global-menu.hook ${pkgdir}/usr/share/tromjaro-layout-switcher
# copy executables
install -d ${pkgdir}/usr/share/applications
install -Dm644 ${srcdir}/tromjaro-layout-switcher.desktop ${pkgdir}/usr/share/applications
install -Dm755 ${srcdir}/layoutSwitcher ${pkgdir}/usr/bin/tromjaro-layout-switcher
install -Dm755 ${srcdir}/toggleGlobalMenu ${pkgdir}/usr/bin/toggle-global-menu
# copy polkit action
install -d ${pkgdir}/usr/share/polkit-1/actions
install -Dm644 com.tromjaro.LayoutSwitcher.policy ${pkgdir}/usr/share/polkit-1/actions
# copy desktop icon
install -d ${pkgdir}/usr/share/icons/hicolor/scalable/apps
install -Dm644 ${srcdir}/tromjaro-layout-switcher.svg ${pkgdir}/usr/share/icons/hicolor/scalable/apps
} }

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
<vendor>TROMjaro</vendor>
<vendor_url>https://www.tromjaro.com/</vendor_url>
<icon_name>tromjaro-layout-switcher</icon_name>
<action id="com.tromjaro.LayoutSwitcher.toggleGlobalMenu">
<description gettext-domain="LayoutSwitcher">Enable or disable global menu</description>
<message gettext-domain="LayoutSwitcher">Authentication is required to enable/disable global menu</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/toggle-global-menu</annotate>
</action>
</policyconfig>

10
disable-global-menu.hook Normal file
View File

@@ -0,0 +1,10 @@
[Trigger]
Operation = Upgrade
Operation = Install
Type = Package
Target = vala-panel-appmenu-registrar-git
[Action]
Description = Disabling global menu...
When = PostTransaction
Exec = /usr/bin/toggle-global-menu disable

View File

@@ -1,65 +0,0 @@
#! /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 ||
zensu SKIP_AUTOSNAP= pacman -S --noconfirm vala-panel-appmenu-registrar ||
{ notify-send 'Error' 'failed installing vala-panel-appmenu-registrar !\nmake sure you type the correct password\nEnabling the internet connection might solve the issue'; exit; }
pacman -Qq vala-panel-appmenu-registrar || 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 ||
zensu SKIP_AUTOSNAP= pacman -R --noconfirm vala-panel-appmenu-registrar ||
{ notify-send 'Error' 'failed removing vala-panel-appmenu-registrar !\nmake sure you type the correct password'; exit; }
pacman -Qq vala-panel-appmenu-registrar && 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 '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/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 2.5 && notify-send "$choice layout was enabled"

169
layoutSwitcher.nim Normal file
View File

@@ -0,0 +1,169 @@
from std/os import symlinkExists, getConfigDir, `/`
from std/envvars import existsEnv, getEnv, delEnv, putEnv
from std/options import Option, some, get, isNone
from std/strutils import toLowerAscii, split
import pkg/owlkettle, ./sharedModule
const
dataDir = "/usr/share/tromjaro-layout-switcher"
iconsDir = dataDir / "icons"
profilesDir = dataDir / "profiles"
# GTK CSS for changing the default icon size and shape of our layout buttons
gtkCSS = """
.layout-button {
min-width: 16.2em;
min-height: 10.4em;
}
"""
appID = "com.tromjaro.LayoutSwitcher"
layoutsGrid = [
[ "Windows-Like (default)", "MacOS-Like (experimental)", "MX-Like" ],
[ "Gnome-Like", "Unity-Like (experimental)", "TopX-Like" ]
]
proc enableTopBarIntegration(): bool =
if not isGlobalMenuEnabled():
# Enable global menu
let exitCode = runCommand("/usr/bin/pkexec", ["/usr/bin/toggle-global-menu", "enable"])
case exitCode
of 0:
discard
of 126:
return false
of 127:
sendNotification(appID, "Layout Switcher", "Authentication failed!")
return false
else:
sendNotification(appID, "Layout Switcher", "Failed to enable global menu!")
return false
# Hide window borders when maximized
discard runCommand("/usr/bin/xfconf-query",
args=["--channel=xfwm4", "--property=/general/borderless_maximize", "--create", "--type=bool", "--set=true"])
# Hide top bar of windows when maximized
discard runCommand("/usr/bin/xfconf-query",
args=["--channel=xfwm4", "--property=/general/titleless_maximize", "--create", "--type=bool", "--set=true"])
# Put window buttons on left side
discard runCommand("/usr/bin/xfconf-query",
args=["--channel=xfwm4", "--property=/general/button_layout", "--create", "--type=string", "--set=CMH|"])
return true
proc disableTopBarIntegration(): bool =
if isGlobalMenuEnabled():
# Disable global menu
let exitCode = runCommand("/usr/bin/pkexec", ["/usr/bin/toggle-global-menu", "disable"])
case exitCode
of 0:
discard
of 126:
return false
of 127:
sendNotification(appID, "Layout Switcher", "Authentication failed!")
else:
sendNotification(appID, "Layout Switcher", "Failed to disable global menu!")
return false
# Hide window borders when maximized
discard runCommand("/usr/bin/xfconf-query",
args=["--channel=xfwm4", "--property=/general/borderless_maximize", "--create", "--type=bool", "--set=true"])
# Don't hide top bar of windows when maximized
discard runCommand("/usr/bin/xfconf-query",
args=["--channel=xfwm4", "--property=/general/titleless_maximize", "--create", "--type=bool", "--set=false"])
# Put window buttons on right side
discard runCommand("/usr/bin/xfconf-query",
args=["--channel=xfwm4", "--property=/general/button_layout", "--create", "--type=string", "--set=|HMC"])
return true
var
oldConfigDir: Option[string]
configDirChanged: bool
# Prevent loading GTK theme from ~/.config/gtk-4.0 directory when it is a symlink
if symlinkExists(getConfigDir() / "gtk-4.0"):
if existsEnv("XDG_CONFIG_HOME"):
oldConfigDir = some(getEnv("XDG_CONFIG_HOME"))
putEnv("XDG_CONFIG_HOME", "/dev/null")
configDirChanged = true
viewable App:
loading: bool
hooks:
build:
# Reset the user's XDG_CONFIG_HOME variable back to what it was before
if configDirChanged == true:
if oldConfigDir.isNone():
delEnv("XDG_CONFIG_HOME")
else:
putEnv("XDG_CONFIG_HOME", get(oldConfigDir))
proc enableLayout(args: tuple[layoutName: string, app: AppState]) {.thread.} =
let
layoutName = args.layoutName
app = args.app
defer:
app.loading = false
app.redrawFromThread()
case layoutName
of "Windows-Like", "MX-Like", "Gnome-Like", "TopX-Like":
if not disableTopBarIntegration():
return
of "Unity-Like", "MacOS-Like":
if not enableTopBarIntegration():
return
else:
return
# Load the layout profile
discard runCommand("/usr/bin/xfce4-panel-profiles", ["load", profilesDir / layoutName & ".tar.bz2"])
# Restart mate-hud
if runCommand("/usr/bin/killall", ["mate-hud"]) == 0:
discard runCommand("/usr/bin/setsid", ["-f", "/usr/lib/mate-hud/mate-hud"])
sendNotification(appID, "Layout Switcher", layoutName & " layout was enabled",
icon = iconsDir / layoutName.toLowerAscii() & "-layout.svg")
var thread: Thread[(string, AppState)]
method view(app: AppState): Widget =
result = gui:
Window:
title = "TROMjaro Layout Switcher"
# Shrink window to the smallest size
defaultSize = (1, 1)
iconName = "tromjaro-layout-switcher"
if app.loading:
Box(orient = OrientY):
Spinner {.vAlign: AlignEnd.}:
spinning = true
sizeRequest = (300, 300)
Label {.vAlign: AlignStart.}:
text = "Loading your layout, please wait..."
else:
Box(orient = OrientY, margin = 7, spacing = 5):
Box(orient = OrientX) {.vAlign: AlignEnd.}:
Label {.hAlign: AlignEnd.}:
text = "Please use the"
LinkButton {.expand: false.}:
text = "Panel Profiles"
proc clicked() =
discard runCommand("/usr/bin/setsid", ["-f", "/usr/bin/xfce4-panel-profiles"])
Label {.hAlign: AlignStart.}:
text = "to save your current configuration in case you did any manual changes, else you may lose them."
Label {.vAlign: AlignStart.}:
text = "Changing to or from any layout that has global menu will require your admin password."
for row in layoutsGrid:
Box(orient = OrientX, spacing = 5) {.vAlign: AlignStart.}:
for tooltip in row:
let layoutName = tooltip.split(' ', 1)[0]
Button {.hAlign: AlignCenter.}:
Picture:
pixbuf = loadPixbuf(iconsDir / layoutName.toLowerAscii() & "-layout.svg")
tooltip = tooltip
style = [ButtonFlat, StyleClass("layout-button")]
proc clicked() =
app.loading = true
createThread(thread, enableLayout, (layoutName, app))
brew(appID, gui(App()), stylesheets=[newStylesheet(gtkCSS)])
if running(thread):
joinThread(thread)

11
sharedModule.nim Normal file
View File

@@ -0,0 +1,11 @@
from std/osproc import startProcess, ProcessOption, waitForExit, close
from std/os import fileExists
proc runCommand*(command: string, args: openArray[string]): int =
## This will run a command with the given args and return its exit code upon completion
let process = startProcess(command, args=args, options={poParentStreams})
result = process.waitForExit()
process.close()
proc isGlobalMenuEnabled*(): bool =
return fileExists("/usr/lib/vala-panel/appmenu-registrar")

58
toggleGlobalMenu.nim Normal file
View File

@@ -0,0 +1,58 @@
from std/osproc import execProcess
from std/strformat import fmt
import sharedModule, std/os
proc enableGlobalMenus(): int =
try:
moveFile("/usr/lib/vala-panel/appmenu-registrar.disabled", "/usr/lib/vala-panel/appmenu-registrar")
removeFile("/usr/share/libalpm/hooks/disable-global-menu.hook")
except:
return 1
proc disableGlobalMenus(): int =
try:
moveFile("/usr/lib/vala-panel/appmenu-registrar", "/usr/lib/vala-panel/appmenu-registrar.disabled")
if not fileExists("/usr/share/libalpm/hooks/disable-global-menu.hook"):
createDir("/usr/share/libalpm/hooks")
copyFileWithPermissions("/usr/share/tromjaro-layout-switcher/disable-global-menu.hook",
"/usr/share/libalpm/hooks/disable-global-menu.hook")
discard runCommand("/usr/bin/killall", ["appmenu-registrar"])
except:
return 1
proc showHelp() =
let executableName = paramStr(0).extractFilename()
echo fmt"""
Usage: {executableName} <option>
Options:
enable enable global menus
disable disable global menus"""
if execProcess("/usr/bin/id", args=["--user"], options={}) != "0\n":
echo "Run this program as root."
quit(1)
var exitCode: int
if paramCount() < 1:
if isGlobalMenuEnabled():
exitCode = disableGlobalMenus()
else:
exitCode = enableGlobalMenus()
else:
case paramStr(1)
of "enable":
if isGlobalMenuEnabled():
echo "Global menus are already enabled."
exitCode = 0
else:
exitCode = enableGlobalMenus()
of "disable":
if not isGlobalMenuEnabled():
echo "Global menus are already disabled."
exitCode = 0
else:
exitCode = disableGlobalMenus()
else:
showHelp()
quit(exitCode)