Update toggleGlobalMenu.nim
This commit is contained in:
parent
33d15f289d
commit
f227866072
|
@ -1,14 +1,24 @@
|
|||
from std/os import paramCount, paramStr, extractFilename
|
||||
from std/osproc import execProcess
|
||||
from std/strformat import fmt
|
||||
import sharedModule
|
||||
import sharedModule, std/os
|
||||
|
||||
proc enableGlobalMenus(): int =
|
||||
return runCommand("/usr/bin/env", ["SKIP_AUTOSNAP=", "/usr/bin/pacman", "-S", "--noconfirm", "vala-panel-appmenu-registrar"])
|
||||
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 =
|
||||
result = runCommand("/usr/bin/env", ["SKIP_AUTOSNAP=", "/usr/bin/pacman", "-R", "--noconfirm", "vala-panel-appmenu-registrar"])
|
||||
if result == 0:
|
||||
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()
|
||||
|
@ -18,6 +28,10 @@ Options:
|
|||
enable install global menus
|
||||
disable remove 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():
|
||||
|
|
Loading…
Reference in New Issue
Block a user