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
b3fa78cf
Verified
Commit
b3fa78cf
authored
Feb 14, 2026
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hyprland/module: ordered insertion and config fix command
parent
5520a33c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
180 additions
and
0 deletions
+180
-0
actions.go
hyprland/actions.go
+12
-0
commands.go
hyprland/commands.go
+5
-0
manager.go
hyprland/manager.go
+163
-0
No files found.
hyprland/actions.go
View file @
b3fa78cf
...
...
@@ -15,6 +15,18 @@ import (
"github.com/urfave/cli/v3"
)
func
HyprlandFixConfigCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
manager
,
err
:=
GetHyprlandManager
(
ctx
)
if
err
!=
nil
{
return
err
}
manager
.
FixConfig
()
color
.
Green
(
"Конфигурация исправлена"
)
return
nil
}
func
HyprlandCheckCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
manager
,
err
:=
GetHyprlandManager
(
ctx
)
if
err
!=
nil
{
...
...
hyprland/commands.go
View file @
b3fa78cf
...
...
@@ -37,6 +37,11 @@ func CommandList() *cli.Command {
Action
:
HyprlandCheckCommand
,
},
{
Name
:
"fix"
,
Usage
:
"Fix config: sort modules into sections by order"
,
Action
:
HyprlandFixConfigCommand
,
},
{
Name
:
"sync-xkb-layouts"
,
Usage
:
"Sync layouts with xkb"
,
Action
:
HyprlandSyncSystemLayouts
,
...
...
hyprland/manager.go
View file @
b3fa78cf
...
...
@@ -434,9 +434,26 @@ func (m *HyprlandManager) enableMessage(module string, disabledGroup []string) s
for
_
,
name
:=
range
disabledGroup
{
msg
+=
fmt
.
Sprintf
(
"
\n
Модуль '%s' отключён (группа)"
,
name
)
}
if
m
.
hasSourcesOutsideSections
()
{
msg
+=
"
\n\n
Внимание: обнаружены модули вне секций. Выполните 'ximperconf hyprland fix' для исправления."
}
return
msg
}
func
(
m
*
HyprlandManager
)
hasSourcesOutsideSections
()
bool
{
sysStart
,
sysEnd
,
sysFound
:=
m
.
findSectionRange
(
sectionSystemModules
)
userStart
,
userEnd
,
userFound
:=
m
.
findSectionRange
(
sectionUserModules
)
for
_
,
src
:=
range
m
.
Sources
{
inSys
:=
sysFound
&&
src
.
LineNumber
>
sysStart
&&
src
.
LineNumber
<
sysEnd
inUser
:=
userFound
&&
src
.
LineNumber
>
userStart
&&
src
.
LineNumber
<
userEnd
if
!
inSys
&&
!
inUser
{
return
true
}
}
return
false
}
// Sections
// Порядок секций: VARS → SYSTEM MODULES → USER MODULES
...
...
@@ -604,6 +621,152 @@ func (m *HyprlandManager) insertLine(at int, line string) {
m
.
Changed
=
true
}
// Сортирует source-строки по секциям и order,
func
(
m
*
HyprlandManager
)
FixConfig
()
{
type
sourceEntry
struct
{
line
string
path
string
order
int
isUser
bool
commented
bool
}
var
entries
[]
sourceEntry
for
_
,
src
:=
range
m
.
Sources
{
isUser
:=
strings
.
HasPrefix
(
src
.
Path
,
"~"
)
name
:=
strings
.
TrimSuffix
(
filepath
.
Base
(
src
.
Path
),
".conf"
)
meta
:=
ParseModuleMeta
(
m
.
GetModuleFile
(
name
,
isUser
))
order
:=
0
if
meta
!=
nil
{
order
=
meta
.
Order
}
entries
=
append
(
entries
,
sourceEntry
{
line
:
m
.
Lines
[
src
.
LineNumber
],
path
:
src
.
Path
,
order
:
order
,
isUser
:
isUser
,
commented
:
src
.
Commented
,
})
}
toRemove
:=
make
(
map
[
int
]
bool
)
for
_
,
src
:=
range
m
.
Sources
{
toRemove
[
src
.
LineNumber
]
=
true
}
if
ln
:=
m
.
findSectionMarker
(
sectionSystemModules
);
ln
>=
0
{
toRemove
[
ln
]
=
true
}
if
ln
:=
m
.
findSectionMarker
(
sectionUserModules
);
ln
>=
0
{
toRemove
[
ln
]
=
true
}
var
cleaned
[]
string
emptyRun
:=
0
for
i
,
line
:=
range
m
.
Lines
{
if
toRemove
[
i
]
{
continue
}
trimmed
:=
strings
.
TrimSpace
(
line
)
if
strings
.
HasPrefix
(
trimmed
,
sectionMarkerPrefix
)
{
hasContent
:=
false
for
j
:=
i
+
1
;
j
<
len
(
m
.
Lines
);
j
++
{
if
toRemove
[
j
]
{
continue
}
jTrimmed
:=
strings
.
TrimSpace
(
m
.
Lines
[
j
])
if
jTrimmed
==
""
||
strings
.
HasPrefix
(
jTrimmed
,
"#"
)
{
continue
}
if
strings
.
HasPrefix
(
jTrimmed
,
sectionMarkerPrefix
)
{
break
}
hasContent
=
true
break
}
if
!
hasContent
{
continue
}
}
if
trimmed
==
""
{
emptyRun
++
if
emptyRun
<=
1
{
cleaned
=
append
(
cleaned
,
line
)
}
}
else
{
emptyRun
=
0
cleaned
=
append
(
cleaned
,
line
)
}
}
for
len
(
cleaned
)
>
0
&&
strings
.
TrimSpace
(
cleaned
[
len
(
cleaned
)
-
1
])
==
""
{
cleaned
=
cleaned
[
:
len
(
cleaned
)
-
1
]
}
m
.
Lines
=
cleaned
m
.
Vars
=
m
.
GetVarList
()
m
.
Sources
=
nil
slices
.
SortStableFunc
(
entries
,
func
(
a
,
b
sourceEntry
)
int
{
if
a
.
isUser
!=
b
.
isUser
{
if
a
.
isUser
{
return
1
}
return
-
1
}
if
a
.
order
!=
b
.
order
{
if
a
.
order
==
0
{
return
1
}
if
b
.
order
==
0
{
return
-
1
}
return
a
.
order
-
b
.
order
}
return
0
})
insertSection
:=
func
(
sectionEntries
[]
sourceEntry
,
user
bool
)
{
if
len
(
sectionEntries
)
==
0
{
return
}
markerLine
:=
m
.
createModulesSection
(
user
)
pos
:=
markerLine
+
1
prevOrder
:=
-
1
for
_
,
e
:=
range
sectionEntries
{
if
prevOrder
>=
0
&&
prevOrder
!=
e
.
order
{
m
.
insertLine
(
pos
,
""
)
pos
++
}
m
.
insertLine
(
pos
,
e
.
line
)
m
.
Sources
=
append
(
m
.
Sources
,
SourceLine
{
Path
:
e
.
path
,
LineNumber
:
pos
,
Commented
:
e
.
commented
,
})
prevOrder
=
e
.
order
pos
++
}
}
var
sysEntries
,
userEntries
[]
sourceEntry
for
_
,
e
:=
range
entries
{
if
e
.
isUser
{
userEntries
=
append
(
userEntries
,
e
)
}
else
{
sysEntries
=
append
(
sysEntries
,
e
)
}
}
insertSection
(
sysEntries
,
false
)
insertSection
(
userEntries
,
true
)
m
.
Changed
=
true
}
// Plugins
func
(
m
*
HyprlandManager
)
GetLoadedPlugins
()
[]
HyprPlugin
{
...
...
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