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
3dc7b17d
Verified
Commit
3dc7b17d
authored
Feb 27, 2026
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hyprland/var: rewrite unset to use manager
parent
762c7f44
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
41 deletions
+8
-41
var-actions.go
hyprland/var-actions.go
+8
-41
No files found.
hyprland/var-actions.go
View file @
3dc7b17d
...
...
@@ -2,15 +2,11 @@ package hyprland
import
(
"context"
"fmt"
"ximperconf/config"
"ximperconf/locale"
"ximperconf/ui"
"fmt"
"os"
"regexp"
"strings"
"github.com/fatih/color"
"github.com/urfave/cli/v3"
)
...
...
@@ -111,46 +107,17 @@ func HyprlandVarSetCommand(ctx context.Context, cmd *cli.Command) error {
return
nil
}
func
hyprlandVarUnset
(
name
string
)
error
{
if
name
==
""
{
color
.
Red
(
locale
.
T
(
"specify variable name"
))
os
.
Exit
(
1
)
}
if
!
regexp
.
MustCompile
(
`^[A-Za-z_][A-Za-z0-9_]*$`
)
.
MatchString
(
name
)
{
color
.
Red
(
locale
.
T
(
"Invalid variable name: %s"
),
name
)
os
.
Exit
(
1
)
}
if
!
config
.
FileExists
(
config
.
Env
.
Hyprland
.
Config
)
{
color
.
Red
(
locale
.
T
(
"Configuration not found: %s"
),
config
.
Env
.
Hyprland
.
Config
)
os
.
Exit
(
1
)
}
data
,
_
:=
os
.
ReadFile
(
config
.
Env
.
Hyprland
.
Config
)
lines
:=
strings
.
Split
(
string
(
data
),
"
\n
"
)
re
:=
regexp
.
MustCompile
(
`^\s*\$`
+
regexp
.
QuoteMeta
(
name
)
+
`\s*=`
)
newLines
:=
make
([]
string
,
0
,
len
(
lines
))
removed
:=
false
for
_
,
l
:=
range
lines
{
if
re
.
MatchString
(
l
)
{
removed
=
true
continue
}
newLines
=
append
(
newLines
,
l
)
func
HyprlandVarUnsetCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
manager
,
err
:=
GetHyprlandManager
(
ctx
)
if
err
!=
nil
{
return
err
}
if
!
removed
{
color
.
Red
(
locale
.
T
(
"variable '%s' not found"
),
name
)
os
.
Exit
(
1
)
name
:=
cmd
.
Args
()
.
Get
(
0
)
if
err
:=
manager
.
UnsetVar
(
name
);
err
!=
nil
{
return
err
}
color
.
Green
(
locale
.
T
(
"Variable '%s' removed"
),
name
)
return
os
.
WriteFile
(
config
.
Env
.
Hyprland
.
Config
,
[]
byte
(
strings
.
Join
(
newLines
,
"
\n
"
)),
0644
)
}
func
HyprlandVarUnsetCommand
(
ctx
context
.
Context
,
cmd
*
cli
.
Command
)
error
{
hyprlandVarUnset
(
cmd
.
Args
()
.
Get
(
0
))
return
nil
}
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