Compare commits
26 Commits
f56041dffc
...
master
Author | SHA1 | Date | |
---|---|---|---|
ec806de9bd | |||
85ac25afcc | |||
3b779b3f67 | |||
b39718516f | |||
72c118a6ee | |||
da7cfce288 | |||
ae83bfbbd6 | |||
e270acc3dd | |||
1f24cd0bf0 | |||
d412f8a653 | |||
07b1641178 | |||
486f650395 | |||
c9a2438c1d | |||
d43af1f7fd | |||
666d24625b | |||
2eb10c5b71 | |||
f2ec92a22d | |||
43c356debb | |||
1f29b13f85 | |||
c020b3626f | |||
ea7d1b8270 | |||
b1dc6d7e29 | |||
779117672e | |||
87ae3a63f5 | |||
b7578dd97f | |||
c60c17100b |
6
Makefile
6
Makefile
@ -1,12 +1,12 @@
|
||||
# makefile for layout-switcher
|
||||
build:
|
||||
makepkg
|
||||
makepkg -s
|
||||
|
||||
install:
|
||||
pamac-installer tromjaro-layout-switcher-*.tar.xz
|
||||
pamac-installer tromjaro-layout-switcher-*.tar.zst
|
||||
|
||||
remove:
|
||||
pamac-installer --remove tromjaro-layout-switcher
|
||||
|
||||
clean:
|
||||
$(RM) -rf src/ pkg/ *.tar.xz
|
||||
$(RM) -rf src/ pkg/ icons.zip profiles.zip *.tar.zst
|
||||
|
97
PKGBUILD
97
PKGBUILD
@ -1,24 +1,33 @@
|
||||
# Maintainer: TROM <contact@tromsite.com>
|
||||
pkgname=tromjaro-layout-switcher
|
||||
pkgver=1.4
|
||||
pkgrel=1
|
||||
pkgver=2
|
||||
pkgrel=4
|
||||
pkgdesc="TROMjaro Layout switcher application"
|
||||
arch=(any)
|
||||
url=""
|
||||
arch=('x86_64')
|
||||
url="https://git.trom.tf/TROMjaro/layout-switcher-package"
|
||||
license=(unknown)
|
||||
depends=('yad'
|
||||
'zensu'
|
||||
'xfce4-panel-profiles'
|
||||
depends=('xfce4-panel-profiles'
|
||||
'vala-panel-appmenu-registrar-git'
|
||||
'util-linux'
|
||||
'xfconf'
|
||||
'polkit'
|
||||
'mate-hud'
|
||||
'psmisc'
|
||||
'pacman'
|
||||
'coreutils'
|
||||
'vala-panel-appmenu-xfce-git'
|
||||
'vala-panel-appmenu-common-git'
|
||||
'libdbusmenu-gtk2'
|
||||
'appmenu-gtk-module')
|
||||
optdepends=('vala-panel-appmenu-registrar')
|
||||
makedepends=('choosenim')
|
||||
provides=('tromjaro-layout-switcher')
|
||||
backup=()
|
||||
options=(!strip)
|
||||
source=("layout-switcher"
|
||||
source=("layoutSwitcher.nim"
|
||||
"toggleGlobalMenu.nim"
|
||||
"sharedModule.nim"
|
||||
"tromjaro-layout-switcher.desktop"
|
||||
"com.tromjaro.LayoutSwitcher.policy"
|
||||
"disable-global-menu.hook"
|
||||
"tromjaro-layout-switcher.svg"
|
||||
"icons.zip::https://www.drive.tromsite.com/s/SWmAcokLcxLB3gM/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')
|
||||
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}/layout-switcher ${pkgdir}/usr/bin/tromjaro-layout-switcher
|
||||
|
||||
# copy icon
|
||||
install -d ${pkgdir}/usr/share/icons/hicolor/scalable/apps
|
||||
install -Dm644 ${srcdir}/tromjaro-layout-switcher.svg ${pkgdir}/usr/share/icons/hicolor/scalable/apps
|
||||
|
||||
prepare() {
|
||||
# Disable telemetry in choosenim if user is running it for the first time
|
||||
[ -f "$HOME"/.choosenim/analytics ] || {
|
||||
mkdir -p "$HOME"/.choosenim
|
||||
touch "$HOME"/.choosenim/analytics
|
||||
}
|
||||
echo 'Install Nim if not already installed:'
|
||||
choosenim stable
|
||||
echo 'Update Nim to the latest stable release:'
|
||||
choosenim update stable
|
||||
echo 'Refresh nimble package list:'
|
||||
"$HOME"/.nimble/bin/nimble --nim:"$HOME"/.nimble/bin/nim refresh
|
||||
echo 'Install owlkettle from the latest git commit:'
|
||||
"$HOME"/.nimble/bin/nimble --nim:"$HOME"/.nimble/bin/nim install owlkettle
|
||||
}
|
||||
build(){
|
||||
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
|
||||
}
|
||||
|
19
com.tromjaro.LayoutSwitcher.policy
Normal file
19
com.tromjaro.LayoutSwitcher.policy
Normal 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
10
disable-global-menu.hook
Normal 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
|
@ -1,60 +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 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
|
||||
|
||||
# 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 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
|
||||
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 ' 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 \
|
||||
--field=!"$icons/windows.png"!'Windows-Like (default)':BTN "kill -USR1 \$YAD_PID; echo -n 'Windows-Like'" \
|
||||
--field=!"$icons/macos.png"!'MacOS-Like (experimental)':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 (experimental)':BTN "kill -USR1 \$YAD_PID; echo -n 'Unity-Like'" \
|
||||
--field=!"$icons/topx.png"!'TopX-Like':BTN "kill -USR1 \$YAD_PID; echo -n 'TopX-Like'"
|
||||
)
|
||||
|
||||
case "$choice" in
|
||||
'Windows-Like'|'MX-Like'|'Gnome-Like'|'TopX-Like')
|
||||
disable-top-bar-integration ;;
|
||||
'Unity-Like'|'MacOS-Like')
|
||||
enable-top-bar-integration ;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
# 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
|
||||
|
||||
sleep 2.5 && notify-send "$choice layout was enabled"
|
169
layoutSwitcher.nim
Normal file
169
layoutSwitcher.nim
Normal 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
11
sharedModule.nim
Normal 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
58
toggleGlobalMenu.nim
Normal 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)
|
Reference in New Issue
Block a user