user097
(John Smith)
March 10, 2023, 6:51pm
1
Two keyboard layouts are installed: English and Russian. Is it possible to somehow make the main GNOME panel change background color when switching to the Russian layout , for example, from black (default) to dark blue?
Reason: when you often have to switch between layouts, it’s terribly inconvenient to look up right, what kind of layout is on (ru/en)
vgaetera
(Vladislav Grigoryev)
March 17, 2023, 7:52am
3
# shell extensions
sudo dnf -y install gnome-extensions-app gnome-shell-extension-user-theme
gnome-extensions enable user-theme@gnome-shell-extensions.gcampax.github.com
# input sources
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('xkb', 'ru')]"
# shell themes
mkdir -p ~/.local/share/themes/custom-us/gnome-shell
tee ~/.local/share/themes/custom-us/gnome-shell/gnome-shell.css << EOF > /dev/null
#panel { background-color: rgba(0,0,0,1); }
#panel:overview { background-color: rgba(0,0,0,.5); }
EOF
mkdir -p ~/.local/share/themes/custom-ru/gnome-shell
tee ~/.local/share/themes/custom-ru/gnome-shell/gnome-shell.css << EOF > /dev/null
#panel { background-color: rgba(1,29,84,1); }
#panel:overview { background-color: rgba(1,29,84,.5); }
EOF
# bash script
mkdir -p ~/.local/bin
tee ~/.local/bin/gnome-panel-color.sh << "EOF" > /dev/null
#!/bin/bash
gsettings monitor org.gnome.desktop.input-sources mru-sources \
| sed -r -e "s/^\S*\s\S*\s'(\S*)'.*$/\
gsettings set org.gnome.shell.extensions.user-theme name custom-\1/e"
EOF
chmod +x ~/.local/bin/gnome-panel-color.sh
# systemd unit
mkdir -p ~/.config/systemd/user
tee ~/.config/systemd/user/gnome-panel-color.service << EOF > /dev/null
[Unit]
Description=Switch GNOME panel color based on input source
[Service]
ExecStart=${HOME}/.local/bin/gnome-panel-color.sh
[Install]
WantedBy=gnome-session.target
EOF
systemctl --user daemon-reload
systemctl --user enable gnome-panel-color.service
systemctl --user restart gnome-panel-color.service