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
1
Merge Requests
1
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
ximper-unified-theme-switcher
Commits
08d30697
Commit
08d30697
authored
Jun 30, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gui: many improvements
parent
f24f565c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
22 deletions
+70
-22
ximper-unified-theme-switcher-gui.sh
ximper-unified-theme-switcher-gui.sh
+70
-22
No files found.
ximper-unified-theme-switcher-gui.sh
View file @
08d30697
...
@@ -3,8 +3,17 @@
...
@@ -3,8 +3,17 @@
# shellcheck source=/usr/bin/shell-config
# shellcheck source=/usr/bin/shell-config
source
shell-config
source
shell-config
CONFIG_DIR
=
"/etc/ximper-unified-theme-switcher"
export
GDK_BACKEND
=
"x11"
CONFIG_FILE
=
"
$CONFIG_DIR
/themes"
SWITCHER_TMP_PATH
=
$(
mktemp
-d
-t
ximper-unified-theme-switcher-gui.XXXXXXX
)
cleanup
()
{
rm
-rf
"
$SWITCHER_TMP_PATH
"
}
trap
"cleanup"
EXIT
SYSTEM_CONFIG_DIR
=
"/etc/ximper-unified-theme-switcher"
SYSTEM_CONFIG_FILE
=
"
$SYSTEM_CONFIG_DIR
/themes"
HOME_CONFIG_DIR
=
"
$HOME
/.config/ximper-unified-theme-switcher"
HOME_CONFIG_DIR
=
"
$HOME
/.config/ximper-unified-theme-switcher"
HOME_CONFIG_FILE
=
"
$HOME_CONFIG_DIR
/themes"
HOME_CONFIG_FILE
=
"
$HOME_CONFIG_DIR
/themes"
...
@@ -12,9 +21,9 @@ HOME_CONFIG_FILE="$HOME_CONFIG_DIR/themes"
...
@@ -12,9 +21,9 @@ HOME_CONFIG_FILE="$HOME_CONFIG_DIR/themes"
# Функция для создания конфига в домашнем каталоге
# Функция для создания конфига в домашнем каталоге
create_config
()
{
create_config
()
{
if
[
"
$(
id
-u
)
"
-eq
0
]
;
then
if
[
"
$(
id
-u
)
"
-eq
0
]
;
then
mkdir
-p
"
$CONFIG_DIR
"
mkdir
-p
"
$
SYSTEM_
CONFIG_DIR
"
touch
"
$CONFIG_FILE
"
touch
"
$
SYSTEM_
CONFIG_FILE
"
echo
"
$CONFIG_FILE
"
echo
"
$
SYSTEM_
CONFIG_FILE
"
else
else
mkdir
-p
"
$HOME_CONFIG_DIR
"
mkdir
-p
"
$HOME_CONFIG_DIR
"
touch
"
$HOME_CONFIG_FILE
"
touch
"
$HOME_CONFIG_FILE
"
...
@@ -24,8 +33,8 @@ create_config() {
...
@@ -24,8 +33,8 @@ create_config() {
cfg_check
()
{
cfg_check
()
{
# Проверка наличия конфига в /etc
# Проверка наличия конфига в /etc
if
[
-f
"
$
CONFIG_FILE
"
]
&&
[
-w
"
$
CONFIG_FILE
"
]
;
then
if
[
-f
"
$
SYSTEM_CONFIG_FILE
"
]
&&
[
-w
"
$SYSTEM_
CONFIG_FILE
"
]
;
then
echo
"
$CONFIG_FILE
"
echo
"
$
SYSTEM_
CONFIG_FILE
"
else
else
# Если нет конфига в /etc, ищем в домашнем каталоге
# Если нет конфига в /etc, ищем в домашнем каталоге
if
[
-f
"
$HOME_CONFIG_FILE
"
]
;
then
if
[
-f
"
$HOME_CONFIG_FILE
"
]
;
then
...
@@ -35,6 +44,7 @@ cfg_check() {
...
@@ -35,6 +44,7 @@ cfg_check() {
fi
fi
fi
fi
}
}
EDITABLE_CONFIG_FILE
=
$(
cfg_check
)
EDITABLE_CONFIG_FILE
=
$(
cfg_check
)
echo
"
$EDITABLE_CONFIG_FILE
"
echo
"
$EDITABLE_CONFIG_FILE
"
...
@@ -113,25 +123,62 @@ kv-themes-list() {
...
@@ -113,25 +123,62 @@ kv-themes-list() {
echo
"
$OUTPUT
"
|
tr
'\n'
'!'
|
sed
's/.$//'
echo
"
$OUTPUT
"
|
tr
'\n'
'!'
|
sed
's/.$//'
}
}
change-style
()
{
local
CURRENT_THEME
CURRENT_THEME
=
$(
gsettings get org.gnome.desktop.interface color-scheme |
awk
-F
"'"
'{print $2}'
)
if
[
"
$CURRENT_THEME
"
==
"default"
]
;
then
NEW_SETTINGS
=
$(
yad
--form
--columns
=
2
\
gsettings
set
org.gnome.desktop.interface color-scheme
'prefer-dark'
--field
=
"Kvantum light theme:CB"
"
$(
kv-themes-list light
)
"
\
else
--field
=
"Kvantum dark theme:CB"
"
$(
kv-themes-list dark
)
"
\
gsettings
set
org.gnome.desktop.interface color-scheme
'default'
--field
=
"GTK3 light theme:CB"
"
$(
gtk3-themes-list light
)
"
\
fi
--field
=
"GTK3 dark theme:CB"
"
$(
gtk3-themes-list dark
)
"
\
}
\
export
-f
change-style
--button
=
"yad-apply:0"
\
--button
=
"yad-cancel:1"
\
YAD_RANDOM
=
$RANDOM
)
while
true
;
do
if
[[
$?
==
252
||
$?
==
1
]]
;
then
yad
--form
\
--plug
=
$YAD_RANDOM
--tabnum
=
1
\
--columns
=
2
--align
=
center
\
--field
=
"change style to light/dark:FBTN"
\
"bash -c 'change-style'"
\
&
yad
--form
\
--plug
=
$YAD_RANDOM
--tabnum
=
2
\
--columns
=
2
-align
=
center
\
\
--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
)
"
\
\
>
"
${
SWITCHER_TMP_PATH
}
/SETTINGS"
\
&
yad
--paned
\
--key
=
$YAD_RANDOM
\
--title
=
"ximper-unified-theme-switcher-gui"
--class
=
"ximper-unified-theme-switcher-gui"
\
--orient
=
vert
--splitter
=
0
--width
=
300
--height
=
200
\
\
--button
=
"yad-apply:0"
\
--button
=
"yad-cancel:1"
if
[[
$?
==
252
||
$?
==
1
]]
;
then
echo
"EXIT"
echo
"EXIT"
exit
0
break
fi
fi
IFS
=
'|'
read
-r
KV_LIGHT KV_DARK GTK3_LIGHT GTK3_DARK
<<<
"
$NEW_SETTINGS
"
NEW_SETTINGS
=
$(
cat
"
$SWITCHER_TMP_PATH
/SETTINGS"
)
IFS
=
'|'
read
-r
KV_LIGHT KV_DARK GTK3_LIGHT GTK3_DARK
<<<
"
$NEW_SETTINGS
"
declare
-A
THEMES
=(
declare
-A
THEMES
=(
[
"KV_LIGHT_THEME"
]=
"
$KV_LIGHT
"
[
"KV_LIGHT_THEME"
]=
"
$KV_LIGHT
"
[
"KV_DARK_THEME"
]=
"
$KV_DARK
"
[
"KV_DARK_THEME"
]=
"
$KV_DARK
"
...
@@ -142,3 +189,4 @@ IFS='|' read -r KV_LIGHT KV_DARK GTK3_LIGHT GTK3_DARK <<< "$NEW_SETTINGS"
...
@@ -142,3 +189,4 @@ IFS='|' read -r KV_LIGHT KV_DARK GTK3_LIGHT GTK3_DARK <<< "$NEW_SETTINGS"
for
THEME
in
"
${
!THEMES[@]
}
"
;
do
for
THEME
in
"
${
!THEMES[@]
}
"
;
do
shell_config_set
"
$EDITABLE_CONFIG_FILE
"
"
$THEME
"
"
${
THEMES
[
$THEME
]
}
"
shell_config_set
"
$EDITABLE_CONFIG_FILE
"
"
$THEME
"
"
${
THEMES
[
$THEME
]
}
"
done
done
done
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