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
b1fa9c96
Verified
Commit
b1fa9c96
authored
Oct 12, 2025
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update distro profiles
- add release-replace
parent
7be9ad37
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
3 deletions
+116
-3
actions.go
create/actions.go
+106
-0
struct.go
create/struct.go
+10
-3
No files found.
create/actions.go
View file @
b1fa9c96
...
...
@@ -45,6 +45,66 @@ func processProfile(prof Profile, dryRun bool, res *Result) {
_
=
createLinkIfMissing
(
sys
,
user
,
dryRun
,
res
)
}
// ----- release-replace -----
for
_
,
rr
:=
range
prof
.
ReleaseReplace
{
src
:=
expandPath
(
rr
.
Src
,
""
)
dest
:=
expandPath
(
rr
.
Dest
,
""
)
sysVer
:=
getSystemVersion
()
if
_
,
err
:=
os
.
Stat
(
dest
);
os
.
IsNotExist
(
err
)
{
res
.
Replaced
=
append
(
res
.
Replaced
,
fmt
.
Sprintf
(
"Не найден: '%s' — пропущен"
,
dest
))
continue
}
data
,
err
:=
os
.
ReadFile
(
dest
)
if
err
!=
nil
{
res
.
Replaced
=
append
(
res
.
Replaced
,
fmt
.
Sprintf
(
"Не удалось прочитать %s: %v"
,
dest
,
err
))
continue
}
content
:=
string
(
data
)
if
strings
.
Contains
(
content
,
"XIMPER_LOCK"
)
{
res
.
Replaced
=
append
(
res
.
Replaced
,
fmt
.
Sprintf
(
"Заблокирован: %s — пропущен"
,
dest
))
continue
}
needReplace
:=
false
fileVer
:=
getFileVersionTag
(
dest
)
if
fileVer
==
""
{
fileVer
=
"0.9.3"
}
if
fileVer
==
""
||
fileVer
!=
sysVer
{
needReplace
=
true
}
if
needReplace
{
if
dryRun
{
res
.
Replaced
=
append
(
res
.
Replaced
,
fmt
.
Sprintf
(
"[Dry-run] Заменён: %s на %s"
,
dest
,
src
))
continue
}
backup
:=
dest
+
".old"
_
=
os
.
Rename
(
dest
,
backup
)
if
err
:=
copyFile
(
src
,
dest
);
err
!=
nil
{
res
.
Replaced
=
append
(
res
.
Replaced
,
fmt
.
Sprintf
(
"Ошибка замены %s: %v"
,
dest
,
err
))
continue
}
res
.
Replaced
=
append
(
res
.
Replaced
,
fmt
.
Sprintf
(
"Обновлён: %s (%s → %s)"
,
dest
,
fileVer
,
sysVer
))
}
else
{
res
.
Replaced
=
append
(
res
.
Replaced
,
fmt
.
Sprintf
(
"Актуально: '%s' — пропущено"
,
dest
))
}
}
// ----- hyprvars -----
for
_
,
v
:=
range
prof
.
HyprVars
{
_
,
err
:=
hyprland
.
HyprlandVarGet
(
v
.
Name
)
...
...
@@ -224,6 +284,51 @@ func createLinkIfMissing(src, dest string, dryRun bool, res *Result) error {
return
nil
}
func
getSystemVersion
()
string
{
data
,
err
:=
os
.
ReadFile
(
"/etc/os-release"
)
if
err
!=
nil
{
return
""
}
lines
:=
strings
.
Split
(
string
(
data
),
"
\n
"
)
for
_
,
line
:=
range
lines
{
if
strings
.
HasPrefix
(
line
,
"VERSION_ID="
)
{
return
strings
.
Trim
(
strings
.
SplitN
(
line
,
"="
,
2
)[
1
],
`"`
)
}
}
for
_
,
line
:=
range
lines
{
if
strings
.
HasPrefix
(
line
,
"VERSION="
)
{
return
strings
.
Trim
(
strings
.
SplitN
(
line
,
"="
,
2
)[
1
],
`"`
)
}
}
return
""
}
func
getFileVersionTag
(
path
string
)
string
{
data
,
err
:=
os
.
ReadFile
(
path
)
if
err
!=
nil
{
return
""
}
content
:=
string
(
data
)
idx
:=
strings
.
Index
(
content
,
"XIMPER_V"
)
if
idx
==
-
1
{
return
""
}
content
=
content
[
idx
+
len
(
"XIMPER_V"
)
:
]
var
version
strings
.
Builder
for
_
,
c
:=
range
content
{
if
(
c
>=
'0'
&&
c
<=
'9'
)
||
c
==
'.'
||
(
c
>=
'a'
&&
c
<=
'z'
)
||
(
c
>=
'A'
&&
c
<=
'Z'
)
{
version
.
WriteRune
(
c
)
}
else
{
break
}
}
return
version
.
String
()
}
func
printTree
(
title
string
,
lines
[]
string
)
{
if
len
(
lines
)
==
0
{
return
...
...
@@ -265,6 +370,7 @@ func CreateConfCommand(ctx context.Context, cmd *cli.Command) error {
printTree
(
"Копируем"
,
res
.
Copies
)
printTree
(
"Создаём ссылки"
,
res
.
Links
)
printTree
(
"Обновляем"
,
res
.
Replaced
)
printTree
(
"Создаём переменные Hyprland"
,
res
.
HyprVars
)
printTree
(
"Синхронизируем раскладку Hyprland"
,
res
.
SyncSystemLayouts
)
...
...
create/struct.go
View file @
b1fa9c96
...
...
@@ -12,15 +12,21 @@ type LinkEntry struct {
User
string
`json:"user"`
}
type
ReleaseReplaceEntry
struct
{
Src
string
`json:"src"`
Dest
string
`json:"dest"`
}
type
HyprVar
struct
{
Name
string
`json:"name"`
Value
string
`json:"value"`
}
type
Profile
struct
{
Binary
string
`json:"binary,omitempty"`
Copy
[]
CopyEntry
`json:"copy,omitempty"`
Links
[]
LinkEntry
`json:"links"`
Binary
string
`json:"binary,omitempty"`
Copy
[]
CopyEntry
`json:"copy,omitempty"`
Links
[]
LinkEntry
`json:"links"`
ReleaseReplace
[]
ReleaseReplaceEntry
`json:"release-replace,omitempty"`
// ----- hyprland -----
SyncSystemLayouts
bool
`json:"sync-system-layouts,omitempty"`
...
...
@@ -34,6 +40,7 @@ type Config struct {
type
Result
struct
{
Links
[]
string
Copies
[]
string
Replaced
[]
string
HyprVars
[]
string
SyncSystemLayouts
[]
string
}
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