45 lines
1.2 KiB
Nim
45 lines
1.2 KiB
Nim
|
from std/os import paramCount, paramStr, extractFilename
|
||
|
from std/strformat import fmt
|
||
|
import sharedModule
|
||
|
|
||
|
proc enableGlobalMenus(): int =
|
||
|
return runCommand("/usr/bin/env", ["SKIP_AUTOSNAP=", "/usr/bin/pacman", "-S", "--noconfirm", "vala-panel-appmenu-registrar"])
|
||
|
|
||
|
proc disableGlobalMenus(): int =
|
||
|
result = runCommand("/usr/bin/env", ["SKIP_AUTOSNAP=", "/usr/bin/pacman", "-R", "--noconfirm", "vala-panel-appmenu-registrar"])
|
||
|
if result == 0:
|
||
|
discard runCommand("/usr/bin/killall", ["appmenu-registrar"])
|
||
|
|
||
|
proc showHelp() =
|
||
|
let executableName = paramStr(0).extractFilename()
|
||
|
echo fmt"""
|
||
|
Usage: {executableName} <option>
|
||
|
Options:
|
||
|
enable install global menus
|
||
|
disable remove global menus"""
|
||
|
|
||
|
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)
|