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 Linux
ximper-unified-theme-switcher
Commits
51034d36
Project 'ximper/ximper-unified-theme-switcher' was moved to 'ximperlinux/ximper-unified-theme-switcher'. Please update any links and bookmarks that may still have the old path.
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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
12 deletions
+61
-12
ximper-unified-theme-switcher-service.sh
ximper-unified-theme-switcher-service.sh
+61
-12
No files found.
ximper-unified-theme-switcher-service.sh
View file @
51034d36
#!/bin/bash
#!/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
()
{
update_kv_theme
()
{
echo
"Updating Kvantum theme to
$1
..."
echo
"Updating Kvantum theme to
$1
..."
echo
"Cfg path:
$2
..."
if
[
"
$1
"
==
"light"
]
;
then
if
[
"
$1
"
==
"light"
]
;
then
kvantummanager
--set
KvGnome
kvantummanager
--set
"
$(
shell_config_get
"
$2
"
KV_LIGHT_THEME
)
"
elif
[
"
$1
"
==
"dark"
]
;
then
elif
[
"
$1
"
==
"dark"
]
;
then
kvantummanager
--set
KvGnomeDark
kvantummanager
--set
"
$(
shell_config_get
"
$2
"
KV_DARK_THEME
)
"
fi
fi
}
}
update_gtk3_theme
()
{
update_gtk3_theme
()
{
echo
"Updating GTK3 theme to
$1
..."
echo
"Updating GTK3 theme to
$1
..."
echo
"Cfg path:
$2
..."
if
[
"
$1
"
==
"light"
]
;
then
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
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
fi
}
}
# Function to check and update the theme
# Function to check and update the theme
check_and_update_themes
()
{
check_and_update_themes
()
{
local
CURRENT_THEME
CURRENT_THEME
=
$(
gsettings get org.gnome.desktop.interface color-scheme |
awk
-F
"'"
'{print $2}'
)
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
if
[
"
$CURRENT_THEME
"
==
"default"
]
;
then
update_kv_theme
"light"
update_kv_theme
"light"
"
$CFG_PATH
"
update_gtk3_theme
"light"
update_gtk3_theme
"light"
"
$CFG_PATH
"
else
else
update_kv_theme
"dark"
update_kv_theme
"dark"
"
$CFG_PATH
"
update_gtk3_theme
"dark"
update_gtk3_theme
"dark"
"
$CFG_PATH
"
fi
fi
}
}
...
@@ -35,9 +80,10 @@ check_and_update_themes() {
...
@@ -35,9 +80,10 @@ check_and_update_themes() {
check_and_update_themes
check_and_update_themes
COUNT
=
0
COUNT
=
0
main
()
{
dbus-monitor
"interface='org.freedesktop.portal.Settings',member=SettingChanged"
|
\
dbus-monitor
"interface='org.freedesktop.portal.Settings',member=SettingChanged"
|
\
while
IFS
=
read
-r
LINE
;
do
while
IFS
=
read
-r
LINE
;
do
local
THEME
THEME
=
$(
echo
"
$LINE
"
|
grep
-E
-o
'string "(prefer-dark|default)"'
)
THEME
=
$(
echo
"
$LINE
"
|
grep
-E
-o
'string "(prefer-dark|default)"'
)
if
[
-n
"
$THEME
"
]
;
then
if
[
-n
"
$THEME
"
]
;
then
...
@@ -49,4 +95,6 @@ while IFS= read -r LINE; do
...
@@ -49,4 +95,6 @@ while IFS= read -r LINE; do
COUNT
=
0
COUNT
=
0
fi
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