Compare commits

..

17 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
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
d43af1f7fd better-manage-global-menu ()
Reviewed-on: 
2024-01-01 15:38:54 +00:00
666d24625b Remove the 3 second delay 2023-12-26 19:02:06 +00:00
2eb10c5b71 Check if thread is running before passing it to joinThread() 2023-12-26 18:48:04 +00:00
f2ec92a22d Change delay from 5 seconds to 3 seconds 2023-12-26 05:22:49 +00:00
6 changed files with 69 additions and 40 deletions

@@ -1,12 +1,13 @@
# Maintainer: TROM <contact@tromsite.com> # Maintainer: TROM <contact@tromsite.com>
pkgname=tromjaro-layout-switcher pkgname=tromjaro-layout-switcher
pkgver=1.4 pkgver=2
pkgrel=1 pkgrel=4
pkgdesc="TROMjaro Layout switcher application" pkgdesc="TROMjaro Layout switcher application"
arch=('x86_64') arch=('x86_64')
url="https://git.trom.tf/TROMjaro/layout-switcher-package" url="https://git.trom.tf/TROMjaro/layout-switcher-package"
license=(unknown) license=(unknown)
depends=('xfce4-panel-profiles' depends=('xfce4-panel-profiles'
'vala-panel-appmenu-registrar-git'
'util-linux' 'util-linux'
'xfconf' 'xfconf'
'polkit' 'polkit'
@@ -15,11 +16,9 @@ depends=('xfce4-panel-profiles'
'pacman' 'pacman'
'coreutils' 'coreutils'
'vala-panel-appmenu-xfce-git' 'vala-panel-appmenu-xfce-git'
'vala-panel-appmenu-common-git'
'libdbusmenu-gtk2' 'libdbusmenu-gtk2'
'appmenu-gtk-module') 'appmenu-gtk-module')
makedepends=('choosenim') makedepends=('choosenim')
optdepends=('vala-panel-appmenu-registrar')
provides=('tromjaro-layout-switcher') provides=('tromjaro-layout-switcher')
backup=() backup=()
options=(!strip) options=(!strip)
@@ -28,6 +27,7 @@ source=("layoutSwitcher.nim"
"sharedModule.nim" "sharedModule.nim"
"tromjaro-layout-switcher.desktop" "tromjaro-layout-switcher.desktop"
"com.tromjaro.LayoutSwitcher.policy" "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")
@@ -38,6 +38,7 @@ sha256sums=('SKIP'
'SKIP' 'SKIP'
'SKIP' 'SKIP'
'SKIP' 'SKIP'
'SKIP'
'SKIP') 'SKIP')
prepare() { prepare() {
# Disable telemetry in choosenim if user is running it for the first time # Disable telemetry in choosenim if user is running it for the first time
@@ -52,7 +53,7 @@ prepare() {
echo 'Refresh nimble package list:' echo 'Refresh nimble package list:'
"$HOME"/.nimble/bin/nimble --nim:"$HOME"/.nimble/bin/nim refresh "$HOME"/.nimble/bin/nimble --nim:"$HOME"/.nimble/bin/nim refresh
echo 'Install owlkettle from the latest git commit:' echo 'Install owlkettle from the latest git commit:'
"$HOME"/.nimble/bin/nimble --nim:"$HOME"/.nimble/bin/nim install owlkettle@#head "$HOME"/.nimble/bin/nimble --nim:"$HOME"/.nimble/bin/nim install owlkettle
} }
build(){ build(){
echo 'Compile layoutSwitcher.nim for release build:' echo 'Compile layoutSwitcher.nim for release build:'
@@ -69,6 +70,9 @@ package() {
install -d ${pkgdir}/usr/share/tromjaro-layout-switcher/profiles install -d ${pkgdir}/usr/share/tromjaro-layout-switcher/profiles
install -Dm644 ${srcdir}/profiles/* ${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 # copy executables
install -d ${pkgdir}/usr/share/applications install -d ${pkgdir}/usr/share/applications
install -Dm644 ${srcdir}/tromjaro-layout-switcher.desktop ${pkgdir}/usr/share/applications install -Dm644 ${srcdir}/tromjaro-layout-switcher.desktop ${pkgdir}/usr/share/applications

@@ -7,8 +7,8 @@
<vendor_url>https://www.tromjaro.com/</vendor_url> <vendor_url>https://www.tromjaro.com/</vendor_url>
<icon_name>tromjaro-layout-switcher</icon_name> <icon_name>tromjaro-layout-switcher</icon_name>
<action id="com.tromjaro.LayoutSwitcher.toggleGlobalMenu"> <action id="com.tromjaro.LayoutSwitcher.toggleGlobalMenu">
<description gettext-domain="LayoutSwitcher">Install or remove global menu</description> <description gettext-domain="LayoutSwitcher">Enable or disable global menu</description>
<message gettext-domain="LayoutSwitcher">Authentication is required to install/remove global menu</message> <message gettext-domain="LayoutSwitcher">Authentication is required to enable/disable global menu</message>
<defaults> <defaults>
<allow_any>auth_admin</allow_any> <allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive> <allow_inactive>auth_admin</allow_inactive>

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,8 +1,8 @@
from std/os import symlinkExists, getConfigDir, `/`, sleep from std/os import symlinkExists, getConfigDir, `/`
from std/envvars import existsEnv, getEnv, delEnv, putEnv from std/envvars import existsEnv, getEnv, delEnv, putEnv
from std/options import Option, some, get, isNone from std/options import Option, some, get, isNone
from std/strutils import toLowerAscii, split from std/strutils import toLowerAscii, split
import owlkettle, sharedModule import pkg/owlkettle, ./sharedModule
const const
dataDir = "/usr/share/tromjaro-layout-switcher" dataDir = "/usr/share/tromjaro-layout-switcher"
@@ -10,14 +10,11 @@ const
profilesDir = dataDir / "profiles" profilesDir = dataDir / "profiles"
# GTK CSS for changing the default icon size and shape of our layout buttons # GTK CSS for changing the default icon size and shape of our layout buttons
gtkCSS = """ gtkCSS = """
.layout-button > image {
-gtk-icon-transform: scale(19);
}
.layout-button { .layout-button {
min-height: 200px; min-width: 16.2em;
min-width: 300px; min-height: 10.4em;
}""" }
"""
appID = "com.tromjaro.LayoutSwitcher" appID = "com.tromjaro.LayoutSwitcher"
layoutsGrid = [ layoutsGrid = [
[ "Windows-Like (default)", "MacOS-Like (experimental)", "MX-Like" ], [ "Windows-Like (default)", "MacOS-Like (experimental)", "MX-Like" ],
@@ -37,7 +34,7 @@ proc enableTopBarIntegration(): bool =
sendNotification(appID, "Layout Switcher", "Authentication failed!") sendNotification(appID, "Layout Switcher", "Authentication failed!")
return false return false
else: else:
sendNotification(appID, "Failed installing global menu!", "Make sure that you are not currently installing any apps or updating the system.\nEnabling internet connection might solve the issue.") sendNotification(appID, "Layout Switcher", "Failed to enable global menu!")
return false return false
# Hide window borders when maximized # Hide window borders when maximized
discard runCommand("/usr/bin/xfconf-query", discard runCommand("/usr/bin/xfconf-query",
@@ -62,7 +59,7 @@ proc disableTopBarIntegration(): bool =
of 127: of 127:
sendNotification(appID, "Layout Switcher", "Authentication failed!") sendNotification(appID, "Layout Switcher", "Authentication failed!")
else: else:
sendNotification(appID, "Failed removing global menu!", "Make sure that you are not currently installing any apps or updating the system.") sendNotification(appID, "Layout Switcher", "Failed to disable global menu!")
return false return false
# Hide window borders when maximized # Hide window borders when maximized
discard runCommand("/usr/bin/xfconf-query", discard runCommand("/usr/bin/xfconf-query",
@@ -121,10 +118,8 @@ proc enableLayout(args: tuple[layoutName: string, app: AppState]) {.thread.} =
# Restart mate-hud # Restart mate-hud
if runCommand("/usr/bin/killall", ["mate-hud"]) == 0: if runCommand("/usr/bin/killall", ["mate-hud"]) == 0:
discard runCommand("/usr/bin/setsid", ["-f", "/usr/lib/mate-hud/mate-hud"]) discard runCommand("/usr/bin/setsid", ["-f", "/usr/lib/mate-hud/mate-hud"])
# Wait 5 seconds for the effects to take place on screen
sleep(5000)
sendNotification(appID, "Layout Switcher", layoutName & " layout was enabled", sendNotification(appID, "Layout Switcher", layoutName & " layout was enabled",
icon = iconsDir / layoutName.toLowerAscii() & "-layout.png") icon = iconsDir / layoutName.toLowerAscii() & "-layout.svg")
var thread: Thread[(string, AppState)] var thread: Thread[(string, AppState)]
@@ -133,15 +128,18 @@ method view(app: AppState): Widget =
Window: Window:
title = "TROMjaro Layout Switcher" title = "TROMjaro Layout Switcher"
# Shrink window to the smallest size # Shrink window to the smallest size
defaultSize = (0, 0) defaultSize = (1, 1)
iconName = "tromjaro-layout-switcher" iconName = "tromjaro-layout-switcher"
if app.loading: if app.loading:
Box(orient = OrientY, margin = 70): Box(orient = OrientY):
Spinner(spinning = true) Spinner {.vAlign: AlignEnd.}:
Label(text = "Loading your layout, please wait...") {.expand: false.} spinning = true
sizeRequest = (300, 300)
Label {.vAlign: AlignStart.}:
text = "Loading your layout, please wait..."
else: else:
Box(orient = OrientY, margin = 7, spacing = 5): Box(orient = OrientY, margin = 7, spacing = 5):
Box(orient = OrientX): Box(orient = OrientX) {.vAlign: AlignEnd.}:
Label {.hAlign: AlignEnd.}: Label {.hAlign: AlignEnd.}:
text = "Please use the" text = "Please use the"
LinkButton {.expand: false.}: LinkButton {.expand: false.}:
@@ -150,20 +148,22 @@ method view(app: AppState): Widget =
discard runCommand("/usr/bin/setsid", ["-f", "/usr/bin/xfce4-panel-profiles"]) discard runCommand("/usr/bin/setsid", ["-f", "/usr/bin/xfce4-panel-profiles"])
Label {.hAlign: AlignStart.}: Label {.hAlign: AlignStart.}:
text = "to save your current configuration in case you did any manual changes, else you may lose them." text = "to save your current configuration in case you did any manual changes, else you may lose them."
Label: Label {.vAlign: AlignStart.}:
text = "Changing to or from any layout that has global menu will require your admin password." text = "Changing to or from any layout that has global menu will require your admin password."
for row in layoutsGrid: for row in layoutsGrid:
Box(orient = OrientX, spacing = 5): Box(orient = OrientX, spacing = 5) {.vAlign: AlignStart.}:
for tooltip in row: for tooltip in row:
let layoutName = tooltip.split(' ', 1)[0] let layoutName = tooltip.split(' ', 1)[0]
Button {.vAlign: AlignCenter, hAlign: AlignCenter.}: Button {.hAlign: AlignCenter.}:
icon = layoutName.toLowerAscii() & "-layout" Picture:
pixbuf = loadPixbuf(iconsDir / layoutName.toLowerAscii() & "-layout.svg")
tooltip = tooltip tooltip = tooltip
style = [ButtonFlat, StyleClass("layout-button")] style = [ButtonFlat, StyleClass("layout-button")]
proc clicked() = proc clicked() =
app.loading = true app.loading = true
createThread(thread, enableLayout, (layoutName, app)) createThread(thread, enableLayout, (layoutName, app))
brew(appID, gui(App()), icons=[iconsDir], stylesheets=[newStylesheet(gtkCSS)]) brew(appID, gui(App()), stylesheets=[newStylesheet(gtkCSS)])
joinThread(thread) if running(thread):
joinThread(thread)

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

@@ -1,22 +1,36 @@
from std/os import paramCount, paramStr, extractFilename from std/osproc import execProcess
from std/strformat import fmt from std/strformat import fmt
import sharedModule import sharedModule, std/os
proc enableGlobalMenus(): int = 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 = proc disableGlobalMenus(): int =
result = runCommand("/usr/bin/env", ["SKIP_AUTOSNAP=", "/usr/bin/pacman", "-R", "--noconfirm", "vala-panel-appmenu-registrar"]) try:
if result == 0: 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"]) discard runCommand("/usr/bin/killall", ["appmenu-registrar"])
except:
return 1
proc showHelp() = proc showHelp() =
let executableName = paramStr(0).extractFilename() let executableName = paramStr(0).extractFilename()
echo fmt""" echo fmt"""
Usage: {executableName} <option> Usage: {executableName} <option>
Options: Options:
enable install global menus enable enable global menus
disable remove 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 var exitCode: int
if paramCount() < 1: if paramCount() < 1: