2

The command I want the system to run when the user changes the current theme is

wallch --changetheme

How can I accomplish that?

Tim
  • 32,274
  • 27
  • 118
  • 177
Leon Vitanos
  • 1,212
  • 4
  • 14
  • 24

2 Answers2

0

Cool question!

There is no easy way that I know of. However, you could set up a script running this command:

gsettings get org.gnome.desktop.interface gtk-theme

will return the current theme:

'Adwaita'

(I'm on GNOME).

So this is the script:

#! /bin/bash

pretheme="$(gsettings get org.gnome.desktop.interface gtk-theme)"

while :
do
    ctheme="$(gsettings get org.gnome.desktop.interface gtk-theme)"
    if [ "$ctheme" = "$pretheme" ]
    then
      echo "nochange"
    else
      wallch --changetheme
    fi
    pretheme="$(gsettings get org.gnome.desktop.interface gtk-theme)"
    sleep 10        
done
Tim
  • 32,274
  • 27
  • 118
  • 177
0

Use dconf watch to monitor for changes in the setting path which you're interested with

#!/bin/bash

while read -r line; do
    [[ -n $line ]] || echo "Change in theme setting detected"
done < <(dconf watch /org/gnome/desktop/interface/gtk-theme)

[[ -n $line ]] is there as workaround because dconf watch fires 3 lines in its output every time a change is detected

Flint
  • 3,121
  • 5
  • 27
  • 50