Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-unified-theme-switcher
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-unified-theme-switcher
Commits
c033537e
Commit
c033537e
authored
Jun 29, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
happy birthday, gui
parent
ed25b01b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
0 deletions
+108
-0
ximper-unified-theme-switcher-gui.sh
ximper-unified-theme-switcher-gui.sh
+108
-0
No files found.
ximper-unified-theme-switcher-gui.sh
0 → 100755
View file @
c033537e
#!/bin/bash
# shellcheck source=/usr/bin/shell-config
source
shell-config
CONFIG_DIR
=
"/etc/ximper-unified-theme-switcher"
CONFIG_FILE
=
"
$CONFIG_DIR
/themes"
HOME_CONFIG_DIR
=
"
$HOME
/.config/ximper-unified-theme-switcher"
HOME_CONFIG_FILE
=
"
$HOME_CONFIG_DIR
/themes"
# Функция для создания конфига в домашнем каталоге
create_config
()
{
if
[
"
$(
id
-u
)
"
-eq
0
]
;
then
mkdir
-p
"
$CONFIG_DIR
"
touch
"
$CONFIG_FILE
"
echo
"
$CONFIG_FILE
"
else
mkdir
-p
"
$HOME_CONFIG_DIR
"
touch
"
$HOME_CONFIG_FILE
"
echo
"
$HOME_CONFIG_FILE
"
fi
}
cfg_check
()
{
# Проверка наличия конфига в /etc
if
[
-f
"
$CONFIG_FILE
"
]
&&
[
-w
"
$CONFIG_FILE
"
]
;
then
echo
"
$CONFIG_FILE
"
else
# Если нет конфига в /etc, ищем в домашнем каталоге
if
[
-f
"
$HOME_CONFIG_FILE
"
]
;
then
echo
"
$HOME_CONFIG_FILE
"
else
create_config
fi
fi
}
EDITABLE_CONFIG_FILE
=
$(
cfg_check
)
echo
"
$EDITABLE_CONFIG_FILE
"
# Вспомогательная функция для обработки списка тем и поиска номера строки
manipulate-list
()
{
local
LIST
=
"
$1
"
local
REPLACE_OBJ
=
"
$2
"
local
LINE_NUMBER
LINE_NUMBER
=
$(
echo
"
$LIST
"
|
grep
-n
"
$REPLACE_OBJ
"
|
cut
-d
:
-f1
)
if
[
"
$LINE_NUMBER
"
=
1
]
;
then
OUTPUT
=
"
$LIST
"
else
OUTPUT
=
$(
echo
"
$LIST
"
|
awk
-v
ln
=
"
$LINE_NUMBER
"
-v
first
=
"
$(
echo
"
$LIST
"
|
head
-n
1
)
"
-v
replace
=
"
$REPLACE_OBJ
"
'
NR == 1 { print replace }
NR == ln { print first }
NR != 1 && NR != ln { print $0 }
'
)
fi
echo
"
$OUTPUT
"
}
gtk3-themes-list
()
{
local
LIST
local
REPLACE_OBJ
local
OUTPUT
LIST
=
$(
basename
-a
/usr/share/themes/
*)
if
[
"
$1
"
==
"light"
]
;
then
REPLACE_OBJ
=
$(
shell_config_get
"
$EDITABLE_CONFIG_FILE
"
GTK3_LIGHT_THEME
)
elif
[
"
$1
"
==
"dark"
]
;
then
REPLACE_OBJ
=
$(
shell_config_get
"
$EDITABLE_CONFIG_FILE
"
GTK3_DARK_THEME
)
else
REPLACE_OBJ
=
""
fi
OUTPUT
=
$(
manipulate-list
"
$LIST
"
"
$REPLACE_OBJ
"
)
echo
"
$OUTPUT
"
|
tr
'\n'
'!'
|
sed
's/.$//'
}
kv-themes-list
()
{
local
LIST
local
REPLACE_OBJ
local
OUTPUT
LIST
=
$(
basename
-a
/usr/share/color-schemes/Kv
*
|
sed
's/\.colors//'
)
if
[
"
$1
"
==
"light"
]
;
then
REPLACE_OBJ
=
$(
shell_config_get
"
$EDITABLE_CONFIG_FILE
"
KV_LIGHT_THEME
)
elif
[
"
$1
"
==
"dark"
]
;
then
REPLACE_OBJ
=
$(
shell_config_get
"
$EDITABLE_CONFIG_FILE
"
KV_DARK_THEME
)
else
REPLACE_OBJ
=
""
fi
OUTPUT
=
$(
manipulate-list
"
$LIST
"
"
$REPLACE_OBJ
"
)
echo
"
$OUTPUT
"
|
tr
'\n'
'!'
|
sed
's/.$//'
}
yad
--form
--columns
=
2
\
--field
=
"Kvantum light theme:CB"
"
$(
kv-themes-list light
)
"
\
--field
=
"Kvantum dark theme:CB"
"
$(
kv-themes-list dark
)
"
\
--field
=
"GTK3 light theme:CB"
"
$(
gtk3-themes-list light
)
"
\
--field
=
"GTK3 dark theme:CB"
"
$(
gtk3-themes-list dark
)
"
\ No newline at end of file
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