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
0fc2d276
Verified
Commit
0fc2d276
authored
Dec 21, 2025
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hyprland/module: add --remove flag to disable command
parent
86c33e0f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
15 deletions
+63
-15
actions.go
hyprland/actions.go
+53
-13
commands.go
hyprland/commands.go
+10
-2
No files found.
hyprland/actions.go
View file @
0fc2d276
...
@@ -280,10 +280,6 @@ func HyprlandSetModule(action string, module string, user bool, onlyNew bool) (s
...
@@ -280,10 +280,6 @@ func HyprlandSetModule(action string, module string, user bool, onlyNew bool) (s
// Уже включён
// Уже включён
if
trim
==
lineFull
||
trim
==
lineTilde
{
if
trim
==
lineFull
||
trim
==
lineTilde
{
found
=
true
if
onlyNew
{
return
""
,
fmt
.
Errorf
(
"модуль '%s' уже присутствует в конфиге — пропущено"
,
module
)
}
return
""
,
fmt
.
Errorf
(
"модуль '%s' уже включён"
,
module
)
return
""
,
fmt
.
Errorf
(
"модуль '%s' уже включён"
,
module
)
}
}
...
@@ -300,11 +296,7 @@ func HyprlandSetModule(action string, module string, user bool, onlyNew bool) (s
...
@@ -300,11 +296,7 @@ func HyprlandSetModule(action string, module string, user bool, onlyNew bool) (s
// Если модуль нигде не найден — добавляем новую строку
// Если модуль нигде не найден — добавляем новую строку
if
!
found
{
if
!
found
{
if
strings
.
HasPrefix
(
sysFile
,
HomeDir
)
{
lines
=
append
(
lines
,
lineFull
)
lines
=
append
(
lines
,
lineTilde
)
}
else
{
lines
=
append
(
lines
,
lineFull
)
}
changed
=
true
changed
=
true
}
}
...
@@ -316,23 +308,61 @@ func HyprlandSetModule(action string, module string, user bool, onlyNew bool) (s
...
@@ -316,23 +308,61 @@ func HyprlandSetModule(action string, module string, user bool, onlyNew bool) (s
case
"disable"
:
case
"disable"
:
for
i
,
l
:=
range
lines
{
for
i
,
l
:=
range
lines
{
trim
:=
strings
.
TrimSpace
(
l
)
// Уже выключен
if
reFull
.
MatchString
(
l
)
||
reTilde
.
MatchString
(
l
)
{
if
reFull
.
MatchString
(
l
)
||
reTilde
.
MatchString
(
l
)
{
return
""
,
fmt
.
Errorf
(
"модуль '%s' уже отключён"
,
module
)
return
""
,
fmt
.
Errorf
(
"модуль '%s' уже отключён"
,
module
)
}
}
if
strings
.
TrimSpace
(
l
)
==
lineFull
||
strings
.
TrimSpace
(
l
)
==
lineTilde
{
// Включён
if
trim
==
lineFull
||
trim
==
lineTilde
{
lines
[
i
]
=
"# "
+
lineFull
lines
[
i
]
=
"# "
+
lineFull
out
=
fmt
.
Sprintf
(
"Модуль '%s' отключён"
,
module
)
changed
=
true
}
}
if
!
changed
{
return
""
,
fmt
.
Errorf
(
"модуль '%s' не найден в конфигурации"
,
module
)
}
case
"remove"
:
// слайс для строк, которые не нужно удалять
newLines
:=
[]
string
{}
for
_
,
l
:=
range
lines
{
trim
:=
strings
.
TrimSpace
(
l
)
// Проверяем все возможные варианты
isModuleLine
:=
trim
==
lineFull
||
trim
==
lineTilde
||
reFull
.
MatchString
(
l
)
||
reTilde
.
MatchString
(
l
)
// Если это не модуль - добавляем в новый список
if
!
isModuleLine
{
newLines
=
append
(
newLines
,
l
)
}
else
{
changed
=
true
changed
=
true
}
}
}
}
// Заменяем lines на отфильтрованные строки
if
changed
{
lines
=
newLines
}
if
!
changed
{
if
!
changed
{
return
""
,
fmt
.
Errorf
(
"модуль '%s' не найден в конфигурации"
,
module
)
return
""
,
fmt
.
Errorf
(
"модуль '%s' не найден в конфигурации"
,
module
)
}
}
out
=
fmt
.
Sprintf
(
"Модуль '%s' отключён"
,
module
)
out
=
fmt
.
Sprintf
(
"Модуль '%s' удалён"
,
module
)
}
if
changed
{
_
=
os
.
WriteFile
(
config
.
Env
.
Hyprland
.
Config
,
[]
byte
(
strings
.
Join
(
lines
,
"
\n
"
)),
0644
)
}
}
_
=
os
.
WriteFile
(
config
.
Env
.
Hyprland
.
Config
,
[]
byte
(
strings
.
Join
(
lines
,
"
\n
"
)),
0644
)
return
out
,
nil
return
out
,
nil
}
}
...
@@ -347,7 +377,17 @@ func HyprlandModuleEnableCommand(ctx context.Context, cmd *cli.Command) error {
...
@@ -347,7 +377,17 @@ func HyprlandModuleEnableCommand(ctx context.Context, cmd *cli.Command) error {
return
nil
return
nil
}
}
func
HyprlandModuleDisableCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
func
HyprlandModuleDisableCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
msg
,
err
:=
HyprlandSetModule
(
"disable"
,
cmd
.
Args
()
.
Get
(
0
),
cmd
.
Bool
(
"user"
),
false
)
remove
:=
cmd
.
Bool
(
"remove"
)
var
msg
string
var
err
error
if
remove
{
msg
,
err
=
HyprlandSetModule
(
"remove"
,
cmd
.
Args
()
.
Get
(
0
),
cmd
.
Bool
(
"user"
),
false
)
}
else
{
msg
,
err
=
HyprlandSetModule
(
"disable"
,
cmd
.
Args
()
.
Get
(
0
),
cmd
.
Bool
(
"user"
),
false
)
}
if
err
!=
nil
{
if
err
!=
nil
{
color
.
Red
(
err
.
Error
())
color
.
Red
(
err
.
Error
())
return
err
return
err
...
...
hyprland/commands.go
View file @
0fc2d276
...
@@ -86,8 +86,16 @@ func CommandList() *cli.Command {
...
@@ -86,8 +86,16 @@ func CommandList() *cli.Command {
ShellComplete
:
ShellCompleteModule
(
"disabled"
),
ShellComplete
:
ShellCompleteModule
(
"disabled"
),
},
},
{
{
Name
:
"disable"
,
Name
:
"disable"
,
Usage
:
"disable module"
,
Usage
:
"disable module"
,
Flags
:
[]
cli
.
Flag
{
&
cli
.
BoolFlag
{
Name
:
"remove"
,
Usage
:
"delete module line from config"
,
Aliases
:
[]
string
{
"r"
},
Value
:
false
,
},
},
ArgsUsage
:
"module"
,
ArgsUsage
:
"module"
,
Action
:
HyprlandModuleDisableCommand
,
Action
:
HyprlandModuleDisableCommand
,
ShellComplete
:
ShellCompleteModule
(
"enabled"
),
ShellComplete
:
ShellCompleteModule
(
"enabled"
),
...
...
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