Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximperconf
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
ximperconf
Commits
665125fd
Verified
Commit
665125fd
authored
Dec 16, 2025
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add check for hyprland config modules
parent
74eec0de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
142 additions
and
14 deletions
+142
-14
actions.go
hyprland/actions.go
+134
-13
commands.go
hyprland/commands.go
+8
-1
No files found.
hyprland/actions.go
View file @
665125fd
...
...
@@ -22,20 +22,28 @@ var (
HomeDir
,
_
=
os
.
UserHomeDir
()
)
func
CheckHyprland
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
h
:=
config
.
Env
.
Hyprland
if
h
==
nil
||
h
.
Config
==
""
{
fmt
.
Println
(
""
)
}
type
HyprConfigError
struct
{
File
string
Line
int
Text
string
}
command
:=
exec
.
Command
(
"hyprland"
,
"--verify-config"
)
output
,
err
:=
command
.
CombinedOutput
()
func
HyprlandCheck
(
configPath
string
)
([]
HyprConfigError
,
error
)
{
cmd
:=
exec
.
Command
(
"hyprland"
,
"--verify-config"
,
"-c"
,
configPath
,
)
output
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
fmt
.
Println
(
""
)
if
_
,
ok
:=
err
.
(
*
exec
.
ExitError
);
!
ok
{
return
nil
,
err
}
}
lines
:=
strings
.
Split
(
string
(
output
),
"
\n
"
)
result
:=
[]
string
{}
results
:=
[]
HyprConfigError
{}
start
:=
false
for
_
,
line
:=
range
lines
{
...
...
@@ -43,11 +51,62 @@ func CheckHyprland(ctx context.Context, cmd *cli.Command) error {
start
=
true
continue
}
if
start
&&
strings
.
TrimSpace
(
line
)
!=
""
{
result
=
append
(
result
,
line
)
if
!
start
{
continue
}
line
=
strings
.
TrimSpace
(
line
)
if
line
==
""
{
continue
}
// вложенные дубли
if
strings
.
Contains
(
line
,
": Config error in file "
)
{
continue
}
prefix
,
msg
,
ok
:=
strings
.
Cut
(
line
,
": "
)
if
!
ok
{
continue
}
var
file
string
var
lineNum
int
_
,
err
:=
fmt
.
Sscanf
(
prefix
,
"Config error in file %s at line %d"
,
&
file
,
&
lineNum
,
)
if
err
!=
nil
{
continue
}
results
=
append
(
results
,
HyprConfigError
{
File
:
file
,
Line
:
lineNum
,
Text
:
msg
,
})
}
return
results
,
nil
}
func
HyprlandCheckCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
h
:=
config
.
Env
.
Hyprland
if
h
==
nil
||
h
.
Config
==
""
{
fmt
.
Println
(
""
)
}
result
,
err
:=
HyprlandCheck
(
h
.
Config
)
if
err
!=
nil
{
color
.
Red
(
err
.
Error
())
return
err
}
for
_
,
e
:=
range
result
{
fmt
.
Printf
(
"%s:%d -> %s
\n
"
,
e
.
File
,
e
.
Line
,
e
.
Text
)
}
fmt
.
Println
(
strings
.
Join
(
result
,
"
\n
"
))
return
nil
}
...
...
@@ -146,6 +205,57 @@ func HyprlandModuleStatusCommand(ctx context.Context, cmd *cli.Command) error {
return
nil
}
func
HyprlandModuleCheck
(
module
string
,
user
bool
,
tmp
bool
)
([]
HyprConfigError
,
error
)
{
if
module
==
""
{
return
nil
,
fmt
.
Errorf
(
"укажите модуль для проверки"
)
}
modulefile
:=
HyprlandGetModuleFile
(
module
,
user
)
if
!
utils
.
FileExists
(
modulefile
)
{
return
nil
,
fmt
.
Errorf
(
"модуль '%s' не найден"
,
module
)
}
if
tmp
{
tmpfile
,
err
:=
os
.
CreateTemp
(
""
,
"ximperconf-hypr-module-check-*.conf"
)
if
err
!=
nil
{
return
nil
,
err
}
defer
os
.
Remove
(
tmpfile
.
Name
())
info
,
_
:=
hyprlandVarInfo
()
for
name
,
value
:=
range
info
{
fmt
.
Fprintf
(
tmpfile
,
"$%s = %s
\n
"
,
name
,
value
)
}
fmt
.
Fprintf
(
tmpfile
,
"source = %s
\n
"
,
modulefile
)
tmpfile
.
Close
()
modulefile
=
tmpfile
.
Name
()
}
info
,
err
:=
HyprlandCheck
(
modulefile
)
if
err
!=
nil
{
return
nil
,
err
}
return
info
,
nil
}
func
HyprlandModuleCheckCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
info
,
err
:=
HyprlandModuleCheck
(
cmd
.
Args
()
.
Get
(
0
),
cmd
.
Bool
(
"user"
),
true
)
if
err
!=
nil
{
color
.
Red
(
err
.
Error
())
return
err
}
for
_
,
e
:=
range
info
{
fmt
.
Printf
(
"%s:%d -> %s
\n
"
,
e
.
File
,
e
.
Line
,
e
.
Text
)
}
return
nil
}
func
HyprlandSetModule
(
action
string
,
module
string
,
user
bool
,
onlyNew
bool
)
(
string
,
error
)
{
sysFile
,
lineFull
,
lineTilde
:=
hyprlandModuleLines
(
module
,
user
)
...
...
@@ -322,10 +432,21 @@ func hyprlandInfoModules(user bool, filter string) {
for
_
,
module
:=
range
modules
{
status
:=
hyprlandModuleStatusStruct
(
module
,
user
)
errors
,
err
:=
HyprlandModuleCheck
(
module
,
user
,
true
)
if
err
!=
nil
{
errors
=
[]
HyprConfigError
{}
}
errornum
:=
len
(
errors
)
desc
:=
""
if
errornum
>
0
{
desc
=
fmt
.
Sprintf
(
"(ошибки: %d)"
,
errornum
)
}
items
=
append
(
items
,
ui
.
TreeItem
{
Name
:
module
,
Status
:
status
,
Description
:
""
,
Description
:
desc
,
})
}
...
...
hyprland/commands.go
View file @
665125fd
...
...
@@ -17,7 +17,7 @@ func CommandList() *cli.Command {
{
Name
:
"check"
,
Usage
:
"Check the Hyprland config"
,
Action
:
CheckHyprl
and
,
Action
:
HyprlandCheckComm
and
,
},
{
Name
:
"sync-xkb-layouts"
,
...
...
@@ -45,6 +45,13 @@ func CommandList() *cli.Command {
},
Commands
:
[]
*
cli
.
Command
{
{
Name
:
"check"
,
Usage
:
"Check Hyprland module"
,
ArgsUsage
:
"module"
,
Action
:
HyprlandModuleCheckCommand
,
ShellComplete
:
ShellCompleteModule
(
"all"
),
},
{
Name
:
"status"
,
Usage
:
"Hyprland module status"
,
ArgsUsage
:
"module"
,
...
...
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