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
51034d36
Commit
51034d36
authored
Jun 17, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for configuration files in /etc and home directories
parent
94cf1411
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
22 deletions
+71
-22
ximper-unified-theme-switcher-service.sh
ximper-unified-theme-switcher-service.sh
+71
-22
No files found.
ximper-unified-theme-switcher-service.sh
View file @
51034d36
#!/bin/bash
# shellcheck source=/usr/bin/shell-config
source
shell-config
CONFIG_FILE
=
"/etc/ximper-unified-theme-switcher/themes"
HOME_CONFIG_DIR
=
"
$HOME
/.config/ximper-unified-theme-switcher"
HOME_CONFIG_FILE
=
"
$HOME_CONFIG_DIR
/themes"
# Функция для создания конфига в домашнем каталоге
create_home_config
()
{
mkdir
-p
"
$HOME_CONFIG_DIR
"
touch
"
$HOME_CONFIG_FILE
"
echo
"Config file created in
$HOME_CONFIG_FILE
"
}
cfg_check
()
{
# Проверка наличия конфига в /etc
if
[
-f
"
$CONFIG_FILE
"
]
;
then
echo
"
$CONFIG_FILE
"
else
# Если нет конфига в /etc, ищем в домашнем каталоге
if
[
-f
"
$HOME_CONFIG_FILE
"
]
;
then
echo
"
$HOME_CONFIG_FILE
"
else
create_home_config
fi
fi
}
update_kv_theme
()
{
echo
"Updating Kvantum theme to
$1
..."
echo
"Cfg path:
$2
..."
if
[
"
$1
"
==
"light"
]
;
then
kvantummanager
--set
KvGnome
kvantummanager
--set
"
$(
shell_config_get
"
$2
"
KV_LIGHT_THEME
)
"
elif
[
"
$1
"
==
"dark"
]
;
then
kvantummanager
--set
KvGnomeDark
kvantummanager
--set
"
$(
shell_config_get
"
$2
"
KV_DARK_THEME
)
"
fi
}
update_gtk3_theme
()
{
echo
"Updating GTK3 theme to
$1
..."
echo
"Cfg path:
$2
..."
if
[
"
$1
"
==
"light"
]
;
then
gsettings
set
org.gnome.desktop.interface gtk-theme
'adw-gtk3'
gsettings
set
org.gnome.desktop.interface gtk-theme
"
\'
$(
shell_config_get
"
$2
"
GTK3_LIGHT_THEME
)
\'
"
elif
[
"
$1
"
==
"dark"
]
;
then
gsettings
set
org.gnome.desktop.interface gtk-theme
'adw-gtk3-dark'
gsettings
set
org.gnome.desktop.interface gtk-theme
"
\'
$(
shell_config_get
"
$2
"
GTK3_DARK_THEME
)
\'
"
fi
}
# Function to check and update the theme
check_and_update_themes
()
{
local
CURRENT_THEME
CURRENT_THEME
=
$(
gsettings get org.gnome.desktop.interface color-scheme |
awk
-F
"'"
'{print $2}'
)
local
CFG_PATH
CFG_PATH
=
$(
cfg_check
)
if
[
-z
"
$(
shell_config_get
"
$CFG_PATH
"
KV_DARK_THEME
)
"
]
;
then
shell_config_set
"
$CFG_PATH
"
KV_LIGHT_THEME
"KvGnome"
shell_config_set
"
$CFG_PATH
"
KV_DARK_THEME
"KvGnomeDark"
fi
if
[
-z
"
$(
shell_config_get
"
$CFG_PATH
"
GTK3_DARK_THEME
)
"
]
;
then
shell_config_set
"
$CFG_PATH
"
GTK3_LIGHT_THEME
"adw-gtk3"
shell_config_set
"
$CFG_PATH
"
GTK3_DARK_THEME
"adw-gtk3-dark"
fi
if
[
"
$CURRENT_THEME
"
==
"default"
]
;
then
update_kv_theme
"light"
update_gtk3_theme
"light"
update_kv_theme
"light"
"
$CFG_PATH
"
update_gtk3_theme
"light"
"
$CFG_PATH
"
else
update_kv_theme
"dark"
update_gtk3_theme
"dark"
update_kv_theme
"dark"
"
$CFG_PATH
"
update_gtk3_theme
"dark"
"
$CFG_PATH
"
fi
}
...
...
@@ -35,18 +80,21 @@ check_and_update_themes() {
check_and_update_themes
COUNT
=
0
dbus-monitor
"interface='org.freedesktop.portal.Settings',member=SettingChanged"
|
\
while
IFS
=
read
-r
LINE
;
do
THEME
=
$(
echo
"
$LINE
"
|
grep
-E
-o
'string "(prefer-dark|default)"'
)
if
[
-n
"
$THEME
"
]
;
then
((
COUNT++
))
if
[
$((
$COUNT
%
2
))
=
0
]
;
then
echo
"
$THEME
"
check_and_update_themes
COUNT
=
0
main
()
{
dbus-monitor
"interface='org.freedesktop.portal.Settings',member=SettingChanged"
|
\
while
IFS
=
read
-r
LINE
;
do
local
THEME
THEME
=
$(
echo
"
$LINE
"
|
grep
-E
-o
'string "(prefer-dark|default)"'
)
if
[
-n
"
$THEME
"
]
;
then
((
COUNT++
))
if
[
$((
$COUNT
%
2
))
=
0
]
;
then
echo
"
$THEME
"
check_and_update_themes
COUNT
=
0
fi
fi
fi
done
done
}
main
\ 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