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
66d140b0
Verified
Commit
66d140b0
authored
Mar 08, 2026
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hyprland/module: add init command to create new modules
parent
89361b7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
0 deletions
+88
-0
actions.go
hyprland/actions.go
+75
-0
commands.go
hyprland/commands.go
+13
-0
No files found.
hyprland/actions.go
View file @
66d140b0
...
...
@@ -341,6 +341,81 @@ func HyprlandModuleListCommand(ctx context.Context, cmd *cli.Command) error {
return
nil
}
func
HyprlandModuleInitCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
name
:=
cmd
.
Args
()
.
Get
(
0
)
if
name
==
""
{
return
errors
.
New
(
locale
.
T
(
"module name not specified"
))
}
var
group
string
if
g
,
short
,
ok
:=
strings
.
Cut
(
name
,
"/"
);
ok
{
group
=
g
name
=
g
+
"-"
+
short
}
manager
,
err
:=
GetHyprlandManager
(
ctx
)
if
err
!=
nil
{
return
err
}
info
:=
manager
.
GetModuleInfo
(
name
)
if
!
info
.
Available
{
return
fmt
.
Errorf
(
locale
.
T
(
"name '%s' is reserved"
),
name
)
}
if
!
info
.
Status
.
IsEqual
(
config
.
ModuleStatus
.
Unknown
)
{
return
fmt
.
Errorf
(
locale
.
T
(
"module '%s' already exists"
),
name
)
}
modulePath
:=
filepath
.
Join
(
manager
.
GetModuleDir
(
true
),
name
+
".conf"
)
template
:=
fmt
.
Sprintf
(
"#---
\n
# summary:
\n
# description:
\n
# group: %s
\n
# order: 0
\n
#---
\n\n
"
,
group
)
if
err
:=
os
.
WriteFile
(
modulePath
,
[]
byte
(
template
),
0644
);
err
!=
nil
{
return
fmt
.
Errorf
(
locale
.
T
(
"failed to create module: %s"
),
err
)
}
manager
.
UserModules
=
append
(
manager
.
UserModules
,
name
)
fmt
.
Println
(
locale
.
T
(
"Module created:"
),
modulePath
)
editor
:=
getEditor
()
editCmd
:=
exec
.
Command
(
editor
,
modulePath
)
editCmd
.
Stdin
=
os
.
Stdin
editCmd
.
Stdout
=
os
.
Stdout
editCmd
.
Stderr
=
os
.
Stderr
if
err
:=
editCmd
.
Run
();
err
!=
nil
{
return
fmt
.
Errorf
(
locale
.
T
(
"failed to start editor: %s"
),
err
)
}
if
!
cmd
.
Bool
(
"enable"
)
{
return
nil
}
errs
,
err
:=
manager
.
CheckModule
(
name
)
if
err
!=
nil
{
return
err
}
if
len
(
errs
)
>
0
{
fmt
.
Println
(
locale
.
T
(
"Module has errors, not enabling:"
))
for
_
,
e
:=
range
errs
{
fmt
.
Printf
(
" %d: %s
\n
"
,
e
.
Line
,
e
.
Text
)
}
return
nil
}
msg
,
err
:=
manager
.
SetModule
(
"enable"
,
name
,
false
)
if
err
!=
nil
{
return
err
}
color
.
Green
(
msg
)
return
nil
}
func
HyprlandModuleEditCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
module
:=
cmd
.
Args
()
.
Get
(
0
)
manager
,
err
:=
GetHyprlandManager
(
ctx
)
...
...
hyprland/commands.go
View file @
66d140b0
...
...
@@ -79,6 +79,19 @@ func CommandList() *cli.Command {
Usage
:
locale
.
T
(
"Hyprland modules"
),
Commands
:
[]
*
cli
.
Command
{
{
Name
:
"init"
,
Usage
:
locale
.
T
(
"Create a new module"
),
ArgsUsage
:
"name"
,
Flags
:
[]
cli
.
Flag
{
&
cli
.
BoolFlag
{
Name
:
"enable"
,
Usage
:
locale
.
T
(
"Check and enable module after editing"
),
Aliases
:
[]
string
{
"e"
},
},
},
Action
:
HyprlandModuleInitCommand
,
},
{
Name
:
"check"
,
Usage
:
locale
.
T
(
"Check Hyprland module"
),
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