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
674826b5
Verified
Commit
674826b5
authored
Feb 27, 2026
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hyprland: simplify duplicate code
parent
ee3864db
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
79 deletions
+49
-79
actions.go
hyprland/actions.go
+5
-3
keyboard-actions.go
hyprland/keyboard-actions.go
+6
-6
manager.go
hyprland/manager.go
+35
-63
plugin-actions.go
hyprland/plugin-actions.go
+2
-6
var-actions.go
hyprland/var-actions.go
+1
-1
No files found.
hyprland/actions.go
View file @
674826b5
...
...
@@ -74,8 +74,10 @@ func HyprlandModuleStatusCommand(ctx context.Context, cmd *cli.Command) error {
}
func
HyprlandModuleCheckCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
module
:=
cmd
.
Args
()
.
Get
(
0
)
user
:=
cmd
.
Bool
(
"user"
)
if
cmd
.
Args
()
.
Get
(
0
)
==
""
{
if
module
==
""
{
return
errors
.
New
(
locale
.
T
(
"specify module name"
))
}
...
...
@@ -84,13 +86,13 @@ func HyprlandModuleCheckCommand(ctx context.Context, cmd *cli.Command) error {
return
err
}
moduleinfo
:=
manager
.
GetModuleInfo
(
cmd
.
Args
()
.
Get
(
0
),
cmd
.
Bool
(
"user"
)
)
moduleinfo
:=
manager
.
GetModuleInfo
(
module
,
user
)
if
!
moduleinfo
.
Available
{
return
errors
.
New
(
locale
.
T
(
"invalid module name"
))
}
result
,
err
:=
manager
.
CheckModule
(
cmd
.
Args
()
.
Get
(
0
),
cmd
.
Bool
(
"user"
)
)
result
,
err
:=
manager
.
CheckModule
(
module
,
user
)
if
err
!=
nil
{
return
err
...
...
hyprland/keyboard-actions.go
View file @
674826b5
...
...
@@ -45,14 +45,14 @@ func HyprlandSyncSystemLayouts(ctx context.Context, cmd *cli.Command) error {
hyprLayouts
:=
manager
.
GetVar
(
"kb_layout"
)
if
force
||
hyprLayouts
==
""
{
if
_
,
err
:=
manager
.
SetVar
(
"kb_layout"
,
sysLayouts
);
err
!=
nil
{
return
fmt
.
Errorf
(
locale
.
T
(
"failed to update kb_layout in Hyprland: %w"
),
err
)
}
color
.
Green
(
locale
.
T
(
"Layout updated!"
))
}
else
{
if
hyprLayouts
!=
""
&&
!
force
{
return
errors
.
New
(
locale
.
T
(
"layout is already set, use '--force' for forced update"
))
}
if
_
,
err
:=
manager
.
SetVar
(
"kb_layout"
,
sysLayouts
);
err
!=
nil
{
return
fmt
.
Errorf
(
locale
.
T
(
"failed to update kb_layout in Hyprland: %w"
),
err
)
}
color
.
Green
(
locale
.
T
(
"Layout updated!"
))
return
nil
}
hyprland/manager.go
View file @
674826b5
...
...
@@ -91,9 +91,9 @@ func NewHyprlandManager() (*HyprlandManager, error) {
manager
.
Vars
=
manager
.
GetVarList
()
manager
.
Sources
=
manager
.
parseSourceLines
()
manager
.
UserModules
=
manager
.
scanModulesDir
(
true
)
manager
.
SystemModules
=
manager
.
scanModulesDir
(
false
)
manager
.
Plugins
=
manager
.
scanPluginsDir
(
)
manager
.
UserModules
=
scanDir
(
manager
.
GetModuleDir
(
true
),
".conf"
)
manager
.
SystemModules
=
scanDir
(
manager
.
GetModuleDir
(
false
),
".conf"
)
manager
.
Plugins
=
scanDir
(
manager
.
PluginsDir
,
".so"
)
manager
.
LoadedPlugins
=
manager
.
GetLoadedPlugins
()
for
_
,
p
:=
range
manager
.
LoadedPlugins
{
...
...
@@ -176,72 +176,65 @@ func (m *HyprlandManager) CheckModule(
func
(
m
*
HyprlandManager
)
GetModuleInfo
(
module
string
,
user
bool
)
HyprModule
{
sysFile
:=
m
.
GetModuleFile
(
module
,
user
)
var
C
onfPath
string
var
c
onfPath
string
if
user
{
C
onfPath
=
"~"
+
strings
.
TrimPrefix
(
sysFile
,
m
.
Home
)
c
onfPath
=
"~"
+
strings
.
TrimPrefix
(
sysFile
,
m
.
Home
)
}
else
{
C
onfPath
=
sysFile
c
onfPath
=
sysFile
}
Available
:=
true
for
_
,
skipModule
:=
range
config
.
HyprlandSkipModules
{
if
module
==
skipModule
{
Available
=
false
}
}
FileExists
:=
config
.
FileExists
(
sysFile
)
available
:=
!
slices
.
Contains
(
config
.
HyprlandSkipModules
,
module
)
fileExists
:=
config
.
FileExists
(
sysFile
)
// Конфиг Hyprland отсутствует
if
!
config
.
FileExists
(
config
.
Env
.
Hyprland
.
Config
)
{
if
F
ileExists
{
if
f
ileExists
{
return
HyprModule
{
Name
:
module
,
Status
:
config
.
ModuleStatus
.
Unused
,
Path
:
sysFile
,
ConfPath
:
C
onfPath
,
Available
:
A
vailable
,
ConfPath
:
c
onfPath
,
Available
:
a
vailable
,
Meta
:
ParseModuleMeta
(
sysFile
),
}
}
return
HyprModule
{
Name
:
module
,
Status
:
config
.
ModuleStatus
.
Missing
,
Available
:
A
vailable
,
Available
:
a
vailable
,
}
}
foundActive
:=
false
foundCommented
:=
false
var
L
ineNumber
int
var
l
ineNumber
int
for
_
,
src
:=
range
m
.
Sources
{
if
src
.
Path
!=
C
onfPath
{
if
src
.
Path
!=
c
onfPath
{
continue
}
if
src
.
Commented
{
foundCommented
=
true
L
ineNumber
=
src
.
LineNumber
l
ineNumber
=
src
.
LineNumber
continue
}
foundActive
=
true
L
ineNumber
=
src
.
LineNumber
l
ineNumber
=
src
.
LineNumber
break
}
// подключен
if
foundActive
{
// файла нет
if
!
F
ileExists
{
if
!
f
ileExists
{
return
HyprModule
{
Name
:
module
,
Status
:
config
.
ModuleStatus
.
Missing
,
LineNumber
:
L
ineNumber
,
Available
:
A
vailable
,
LineNumber
:
l
ineNumber
,
Available
:
a
vailable
,
}
}
// файл есть
...
...
@@ -249,9 +242,9 @@ func (m *HyprlandManager) GetModuleInfo(module string, user bool) HyprModule {
Name
:
module
,
Status
:
config
.
ModuleStatus
.
Enabled
,
Path
:
sysFile
,
ConfPath
:
C
onfPath
,
LineNumber
:
L
ineNumber
,
Available
:
A
vailable
,
ConfPath
:
c
onfPath
,
LineNumber
:
l
ineNumber
,
Available
:
a
vailable
,
Meta
:
ParseModuleMeta
(
sysFile
),
}
}
...
...
@@ -262,11 +255,11 @@ func (m *HyprlandManager) GetModuleInfo(module string, user bool) HyprModule {
Name
:
module
,
Status
:
config
.
ModuleStatus
.
Disabled
,
Path
:
sysFile
,
ConfPath
:
C
onfPath
,
LineNumber
:
L
ineNumber
,
Available
:
A
vailable
,
ConfPath
:
c
onfPath
,
LineNumber
:
l
ineNumber
,
Available
:
a
vailable
,
}
if
F
ileExists
{
if
f
ileExists
{
mod
.
Meta
=
ParseModuleMeta
(
sysFile
)
}
else
{
mod
.
Path
=
""
...
...
@@ -275,13 +268,13 @@ func (m *HyprlandManager) GetModuleInfo(module string, user bool) HyprModule {
}
// файл есть, но строка отсутствует
if
F
ileExists
{
if
f
ileExists
{
return
HyprModule
{
Name
:
module
,
Status
:
config
.
ModuleStatus
.
Unused
,
Path
:
sysFile
,
ConfPath
:
C
onfPath
,
Available
:
A
vailable
,
ConfPath
:
c
onfPath
,
Available
:
a
vailable
,
Meta
:
ParseModuleMeta
(
sysFile
),
}
}
...
...
@@ -290,7 +283,7 @@ func (m *HyprlandManager) GetModuleInfo(module string, user bool) HyprModule {
return
HyprModule
{
Name
:
module
,
Status
:
config
.
ModuleStatus
.
Unknown
,
Available
:
A
vailable
,
Available
:
a
vailable
,
}
}
...
...
@@ -1126,40 +1119,19 @@ func (m *HyprlandManager) FindModuleByPath(filePath string) (name string, isUser
return
""
,
false
,
false
}
func
(
m
*
HyprlandManager
)
scanModulesDir
(
user
bool
)
[]
string
{
dir
:=
m
.
GetModuleDir
(
user
)
func
scanDir
(
dir
,
suffix
string
)
[]
string
{
entries
,
err
:=
os
.
ReadDir
(
dir
)
if
err
!=
nil
{
return
nil
}
var
modules
[]
string
var
names
[]
string
for
_
,
e
:=
range
entries
{
if
e
.
IsDir
()
||
!
strings
.
HasSuffix
(
e
.
Name
(),
".conf"
)
{
if
e
.
IsDir
()
||
!
strings
.
HasSuffix
(
e
.
Name
(),
suffix
)
{
continue
}
modules
=
append
(
modules
,
strings
.
TrimSuffix
(
e
.
Name
(),
".conf"
))
names
=
append
(
names
,
strings
.
TrimSuffix
(
e
.
Name
(),
suffix
))
}
return
modules
}
func
(
m
*
HyprlandManager
)
scanPluginsDir
()
[]
string
{
var
list
[]
string
entries
,
err
:=
os
.
ReadDir
(
m
.
PluginsDir
)
if
err
!=
nil
{
return
list
}
for
_
,
e
:=
range
entries
{
if
e
.
IsDir
()
||
!
strings
.
HasSuffix
(
e
.
Name
(),
".so"
)
{
continue
}
name
:=
strings
.
TrimSuffix
(
e
.
Name
(),
".so"
)
list
=
append
(
list
,
name
)
}
return
list
return
names
}
func
normalizeHyprlandLine
(
line
,
home
string
)
string
{
...
...
hyprland/plugin-actions.go
View file @
674826b5
...
...
@@ -59,12 +59,8 @@ func HyprlandPluginInfoCommand(ctx context.Context, cmd *cli.Command) error {
for
_
,
plugin
:=
range
plugins
{
status
:=
manager
.
GetPluginStatus
(
plugin
)
desc
:=
""
if
status
.
IsEqual
(
config
.
PluginStatus
.
Loaded
)
{
for
_
,
plug
:=
range
manager
.
LoadedPlugins
{
if
plug
.
Name
==
plugin
{
desc
=
plug
.
Description
}
}
if
plug
,
ok
:=
manager
.
LoadedPluginsMap
[
plugin
];
ok
{
desc
=
plug
.
Description
}
items
=
append
(
items
,
ui
.
TreeItem
{
Name
:
plugin
,
...
...
hyprland/var-actions.go
View file @
674826b5
...
...
@@ -38,7 +38,7 @@ func HyprlandVarInfoCommand(ctx context.Context, cmd *cli.Command) error {
return
err
}
info
:=
manager
.
GetVarList
()
info
:=
manager
.
Vars
if
len
(
info
)
==
0
{
if
config
.
IsJSON
(
cmd
)
{
...
...
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