Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-shell-panel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-shell-panel
Commits
2df20d57
Verified
Commit
2df20d57
authored
May 22, 2026
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generate runtime waybar config and styles
parent
384be8f5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
14 deletions
+74
-14
README.md
README.md
+2
-0
config.go
config.go
+20
-2
generate.go
generate.go
+36
-1
main.go
main.go
+1
-1
runner.go
runner.go
+15
-10
No files found.
README.md
View file @
2df20d57
...
...
@@ -9,6 +9,8 @@ user-facing configuration UI is expected to live in `ximperconf shell panel`.
-
User config:
`~/.config/ximper-shell/panel/config.json`
-
User modules:
`~/.config/ximper-shell/panel/modules.json`
-
User style:
`~/.config/ximper-shell/panel/style.css`
-
User dark style:
`~/.config/ximper-shell/panel/style-dark.css`
-
System modules:
`/usr/share/ximperdistro/wm/base/waybar/modules.json`
## Commands
...
...
config.go
View file @
2df20d57
...
...
@@ -13,6 +13,8 @@ const (
SystemConfigHome
=
"/usr/share/ximperdistro/wm/base"
SystemWaybarDir
=
SystemConfigHome
+
"/waybar"
ModulesFile
=
SystemWaybarDir
+
"/modules.json"
StyleFile
=
SystemWaybarDir
+
"/style.css"
DarkStyleFile
=
SystemWaybarDir
+
"/style-dark.css"
)
type
Config
struct
{
...
...
@@ -81,16 +83,32 @@ func UserModulesPath() string {
return
filepath
.
Join
(
os
.
Getenv
(
"HOME"
),
".config"
,
"ximper-shell"
,
"panel"
,
"modules.json"
)
}
func
UserStylePath
()
string
{
return
filepath
.
Join
(
os
.
Getenv
(
"HOME"
),
".config"
,
"ximper-shell"
,
"panel"
,
"style.css"
)
}
func
UserDarkStylePath
()
string
{
return
filepath
.
Join
(
os
.
Getenv
(
"HOME"
),
".config"
,
"ximper-shell"
,
"panel"
,
"style-dark.css"
)
}
func
RuntimeDir
()
string
{
return
filepath
.
Join
(
os
.
TempDir
(),
"ximper-shell"
,
"panel"
)
}
func
RuntimeWaybarDir
()
string
{
return
filepath
.
Join
(
RuntimeDir
(),
"waybar"
)
}
func
RuntimeConfigPath
()
string
{
return
filepath
.
Join
(
Runtime
Dir
(),
"config.jsonc
"
)
return
filepath
.
Join
(
Runtime
WaybarDir
(),
"config
"
)
}
func
RuntimeModulesPath
()
string
{
return
filepath
.
Join
(
RuntimeDir
(),
"modules.jsonc"
)
return
filepath
.
Join
(
RuntimeWaybarDir
(),
"modules.jsonc"
)
}
func
RuntimeStylePath
(
name
string
)
string
{
return
filepath
.
Join
(
RuntimeWaybarDir
(),
name
)
}
func
RuntimePIDPath
()
string
{
...
...
generate.go
View file @
2df20d57
...
...
@@ -69,6 +69,9 @@ func GenerateRuntimeConfig() ([]byte, error) {
if
err
:=
WriteRuntimeModules
(
registry
);
err
!=
nil
{
return
nil
,
err
}
if
err
:=
WriteRuntimeStyles
();
err
!=
nil
{
return
nil
,
err
}
return
GenerateConfig
(
cfg
,
registry
)
}
...
...
@@ -102,18 +105,45 @@ func WriteRuntimeModules(registry Registry) error {
return
os
.
WriteFile
(
RuntimeModulesPath
(),
data
,
0644
)
}
func
WriteRuntimeStyles
()
error
{
if
err
:=
os
.
MkdirAll
(
RuntimeWaybarDir
(),
0755
);
err
!=
nil
{
return
err
}
if
err
:=
writeRuntimeStyle
(
RuntimeStylePath
(
"style.css"
),
StyleFile
,
UserStylePath
());
err
!=
nil
{
return
err
}
userDarkStyle
:=
UserStylePath
()
if
fileExists
(
UserDarkStylePath
())
{
userDarkStyle
=
UserDarkStylePath
()
}
return
writeRuntimeStyle
(
RuntimeStylePath
(
"style-dark.css"
),
DarkStyleFile
,
userDarkStyle
)
}
func
writeRuntimeStyle
(
runtimePath
,
systemPath
,
userPath
string
)
error
{
data
:=
"@import url(
\"
"
+
systemPath
+
"
\"
);
\n
"
if
fileExists
(
userPath
)
{
data
+=
"@import url(
\"
"
+
userPath
+
"
\"
);
\n
"
}
return
os
.
WriteFile
(
runtimePath
,
[]
byte
(
data
),
0644
)
}
func
loadInputs
()
(
Config
,
Registry
,
error
)
{
cfg
,
err
:=
LoadConfig
(
UserConfigPath
())
if
err
!=
nil
{
return
Config
{},
Registry
{},
err
}
registry
,
err
:=
LoadMergedRegistry
(
ModulesFile
,
UserModulesPath
())
registry
,
err
:=
loadRegistry
()
if
err
!=
nil
{
return
Config
{},
Registry
{},
err
}
return
cfg
,
registry
,
nil
}
func
loadRegistry
()
(
Registry
,
error
)
{
return
LoadMergedRegistry
(
ModulesFile
,
UserModulesPath
())
}
func
resolveModuleList
(
modules
[]
string
,
position
string
,
registry
Registry
)
([]
string
,
error
)
{
resolved
:=
make
([]
string
,
0
,
len
(
modules
))
for
_
,
module
:=
range
modules
{
...
...
@@ -125,3 +155,8 @@ func resolveModuleList(modules []string, position string, registry Registry) ([]
}
return
resolved
,
nil
}
func
fileExists
(
path
string
)
bool
{
_
,
err
:=
os
.
Stat
(
path
)
return
err
==
nil
}
main.go
View file @
2df20d57
...
...
@@ -82,7 +82,7 @@ func applyCommandSetting(cliCommand *cli.Command) {
}
func
listModulesCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
registry
,
err
:=
LoadMergedRegistry
(
ModulesFile
,
UserModulesPath
()
)
registry
,
err
:=
loadRegistry
(
)
if
err
!=
nil
{
return
err
}
...
...
runner.go
View file @
2df20d57
...
...
@@ -17,8 +17,7 @@ func StartWaybar() error {
return
nil
}
configPath
,
err
:=
GenerateAndWriteRuntimeConfig
()
if
err
!=
nil
{
if
_
,
err
:=
GenerateAndWriteRuntimeConfig
();
err
!=
nil
{
return
err
}
...
...
@@ -28,8 +27,8 @@ func StartWaybar() error {
}
defer
logFile
.
Close
()
cmd
:=
exec
.
Command
(
"waybar"
,
"-c"
,
configPath
)
cmd
.
Env
=
append
(
os
.
Environ
(),
"XDG_CONFIG_HOME="
+
SystemConfigHome
)
cmd
:=
exec
.
Command
(
"waybar"
)
cmd
.
Env
=
append
(
os
.
Environ
(),
"XDG_CONFIG_HOME="
+
RuntimeDir
()
)
cmd
.
Stdout
=
logFile
cmd
.
Stderr
=
logFile
cmd
.
Stdin
=
nil
...
...
@@ -143,12 +142,18 @@ func isPanelProcess(pid int) bool {
}
hasWaybar
:=
bytes
.
Contains
([]
byte
(
filepath
.
Base
(
string
(
parts
[
0
]))),
[]
byte
(
"waybar"
))
hasConfig
:=
false
for
_
,
part
:=
range
parts
[
1
:
]
{
if
string
(
part
)
==
RuntimeConfigPath
()
{
hasConfig
=
true
break
return
hasWaybar
&&
hasPanelConfigHome
(
pid
)
}
func
hasPanelConfigHome
(
pid
int
)
bool
{
data
,
err
:=
os
.
ReadFile
(
filepath
.
Join
(
"/proc"
,
strconv
.
Itoa
(
pid
),
"environ"
))
if
err
!=
nil
{
return
false
}
for
_
,
part
:=
range
bytes
.
Split
(
bytes
.
TrimRight
(
data
,
"
\x00
"
),
[]
byte
{
0
})
{
if
string
(
part
)
==
"XDG_CONFIG_HOME="
+
RuntimeDir
()
{
return
true
}
}
return
hasWaybar
&&
hasConfig
return
false
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment