-
Notifications
You must be signed in to change notification settings - Fork 5
/
knightadjuster
executable file
·93 lines (77 loc) · 2.43 KB
/
knightadjuster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
CONFIG=~/.config/knightadjusterrc
THRESHOLD_DARK=4800
PLASMA_DARK=BreezeDark
PLASMA_LIGHT=BreezeClassic
CURSOR_DARK=Breeze_Snow
CURSOR_LIGHT=breeze_cursors
ICON_DARK=breeze-dark
ICON_LIGHT=breeze
KONSOLE_DARK=Dark
KONSOLE_LIGHT=Light
CHROME_DARK=1
CHROME_LIGHT=9
BIN_PLASMA=plasma-apply-colorscheme
BIN_CURSOR=plasma-apply-cursortheme
BIN_WALLPAPER=plasma-apply-wallpaperimage
BIN_ICON=$(locate plasma-changeicons)
export DISPLAY=:0
export XDG_RUNTIME_DIR=/run/user/$(id -u)
if [ -e "$CONFIG" ]; then . "$CONFIG"; fi
if [ $(qdbus org.kde.KWin /ColorCorrect org.kde.kwin.ColorCorrect.currentTemperature) -lt $THRESHOLD_DARK ]; then
plasmacolors=$PLASMA_DARK
cursorcolors=$CURSOR_DARK
iconcolors=$ICON_DARK
konsolecolors=$KONSOLE_DARK
chromecolors=$CHROME_DARK
wallpaper=$WALLPAPER_DARK
else
plasmacolors=$PLASMA_LIGHT
cursorcolors=$CURSOR_LIGHT
iconcolors=$ICON_LIGHT
konsolecolors=$KONSOLE_LIGHT
chromecolors=$CHROME_LIGHT
wallpaper=$WALLPAPER_LIGHT
fi
plasmacurrent=$PLASMA_LIGHT
if [ "x$(qdbus org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read org.freedesktop.appearance color-scheme)" = x1 ]; then
plasmacurrent=$PLASMA_DARK
fi
if [ $plasmacurrent = $plasmacolors ]; then
echo no change $plasmacurrent
exit
fi
$BIN_PLASMA $plasmacolors
$BIN_CURSOR $cursorcolors
$BIN_ICON $iconcolors
if [ "x$wallpaper" != x ]; then
$BIN_WALLPAPER $wallpaper
fi
dbuskonsole=$(qdbus | grep konsole)
if [ "x$dbuskonsole" = x ]; then
sed -i s/DefaultProfile=.*/DefaultProfile=$konsolecolors.profile/ ~/.config/konsolerc
else
for bus in $dbuskonsole; do
for win in $(qdbus $bus | grep /Windows/); do
qdbus $bus $win org.kde.konsole.Window.setDefaultProfile $konsolecolors
break
done
for ses in $(qdbus $bus | grep /Sessions/); do
qdbus $bus $ses org.kde.konsole.Session.setProfile $konsolecolors
done
done
fi
chromepid=$(pgrep chrome)
chromedark=$(grep -o enable-force-dark ~/.config/google-chrome*/'Local State')
if [ "x$chromedark" = x ]; then
true
elif [ "x$chromepid" = x ]; then
sed -i s/enable-force-dark@./enable-force-dark@$chromecolors/ ~/.config/google-chrome*/'Local State'
else
if kdialog --yesno 'Restart chrome?'; then
pkill -INT -f chrome
pidwait chrome
sed -i s/enable-force-dark@./enable-force-dark@$chromecolors/ ~/.config/google-chrome*/'Local State'
qdbus org.kde.klauncher5 /KLauncher org.kde.KLauncher.kdeinit_exec google-chrome --restore-last-session "" ""
fi
fi