4

I forked the Ambiance theme to create my own one which I maintain. I wonder what's the best way to develop Ubuntu themes.

My current solution is:

  1. Have the theme directory into ~/Documents/foo
  2. I make edits in the CSS files.
  3. sudo rm -rf /usr/share/themes/foo && cp -r ~/Documents/foo /usr/share/themes/
  4. Select Ambiance and then Foo via Unity Tweak Tool.

Most probably there is a better way to do this.

What is the recommended way? I wonder how the Ambiance developers do it.

  • I tend to do it like this: http://askubuntu.com/questions/47643/how-do-i-make-a-theme-from-scratch-for-unity I doubt there is a "right" way. – Rinzwind Mar 07 '15 at 18:48
  • @Rinzwind I saw your answer, but I'm not so happy with it. I prefer keeping the theme into a separate directory (which is also a git repository). Actually my question could be how to update the theme while developing it?. – Ionică Bizău Mar 07 '15 at 18:59

1 Answers1

2

To just automate this process you could use a symlink.... remove the foo directory and create the symlink to it.

ln -s -T /home/youruser/Documents/foo /usr/share/themes/foo

In this way the only thing you have to do is step 4 , because you work always on the newest build. With this the permissions should be right and also you can git push it to your account. If something should be unclear just write a comment and i will explain it more. I dont have a official source, thats just the way i would do it... and maybe the reason why you cant find anything online about this. When this is setup you can create a watch process on file changes that executes point 4 Inotify.

EDIT Working Theme Auto-Reload: This will reload all your theme settings

First of all you need some packages to check for disk changes and the unity-tweak-tool

sudo apt-get install inotify-tools unity-tweak-tool

Remove your existing theme folder, remember for all my tests i took a WinXP theme as test.

sudo mv /usr/share/themes/WinXP/ /usr/share/themes/WinXP-backup/

Link your github theme folder

sudo ln -s -T /home/snapo/Downloads/WinXP/ /usr/share/themes/WinXP/

Just for security reasons create a copy of your software-center

sudo cp -a /usr/share/software-center /usr/share/software-center-backup

Create a file with this content in your home folder like i had it in /home/snapo/autothemechange.sh

#! /bin/bash
##############################################################################################
DIRECTORY_TO_OBSERVE="/usr/share/themes/WinXP/"     ###### might want to change this #########
MYTHEMENAME="WinXP"                                 ###### your theme directory name #########
LOGFILE="/home/snapo/log-theme-change.log"          ###### Logfile to see when change happen #
##############################################################################################

function detect_theme_change {
  inotifywait -r \
    -e modify,move,create,delete \
    $DIRECTORY_TO_OBSERVE
}
while detect_theme_change; do
  now="$(date)"
  echo "Theme has been changed $now" >> $LOGFILE ;
  /usr/bin/gtk-update-icon-cache
  /usr/bin/gtk-update-icon-cache-3.0
  /usr/bin/xdg-user-dirs-gtk-update

  # reset GTK COLOR SCHEME (Unity, GNOME3, Cinnamon, MATE, GNOME2)
  gsettings set org.gnome.desktop.interface gtk-color-scheme ""
  # mateconftool-2 --type=string --set /desktop/mate/interface/gtk_color_scheme ""
  gconftool-2 --type=string --set /desktop/gnome/interface/gtk_color_scheme ""
  gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'Main.loadTheme();' ;

    # change gtk theme (Unity, GNOME3, Cinnamon, MATE, GNOME2)
  gsettings set org.gnome.desktop.interface gtk-theme "$MYTHEMENAME"
  # mateconftool-2 --type=string --set /desktop/mate/interface/gtk_theme "$MYTHEMENAME"
  gconftool-2 --type=string --set /desktop/gnome/interface/gtk_theme "$MYTHEMENAME"

  # reset / change window theme (Unity, GNOME3, Cinnamon, MATE, GNOME2)
  gsettings set org.gnome.desktop.wm.preferences theme "$MYTHEMENAME"
  gconftool --type=string --set /desktop/cinnamon/windows/theme "$MYTHEMENAME"
  gconftool-2 --type=string --set /apps/metacity/general/theme "$MYTHEMENAME"
  # mateconftool-2 --type=string --set /apps/marco/general/theme "$MYTHEMENAME"

  # change shell theme
  gsettings set org.gnome.shell.extensions.user-theme name "$MYTHEMENAME"
  gsettings set org.cinnamon.theme name "$MYTHEMENAME"

done

When you have done this, set it to chmod 755

chmod 755 /home/snapo/autothemechange.sh

Remember, the script will put out many errors, because i will reload the most theme engines... that means if you use gtk3 all others give out a error, if you use unity the same to the others... please ignore them.

There are 3 Variables you need to edit before you run it the first time, description for each variable is at the right side of the variable.

IF you want that the script automatically starts when you login (which i dont recommend for inotify) then you can do the following:

System > Preferences > Startup Applications:

bash /home/snapo/autothemeupdate.sh

i recommend creating a link on the desktop, so while you start developing, you doubleclick the link.

snapo
  • 216
  • I already tried with a symlink, but strangely without disabling and enabling the theme, the changes are not updated. – Ionică Bizău Mar 25 '15 at 14:51
  • are you using gtk3? if yes another askubuntu user may already answered this Reload Theme – snapo Mar 25 '15 at 15:29
  • I guess so: https://github.com/IonicaBizau/Flattiance/tree/master/Flattiance – Ionică Bizău Mar 25 '15 at 15:30
  • ok , i will create later in the evening a startup script that starts a watch process and reloads the theme on a change with the help of the Reload Theme link. Im @work at the moment , please give me the time – snapo Mar 25 '15 at 15:34
  • You have 3 days. :) Really looking for such a script. – Ionică Bizău Mar 25 '15 at 15:39
  • sorry that it took so long, had many things to test with the different engines, where i didnt know on which you are developing. Please give it a try, if something should not work, let me know and i will adjust the script. (it looks ugly because it was written quickly) – snapo Mar 25 '15 at 22:41
  • ./watch.sh: line 23: mateconftool-2: command not found, Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such method 'Eval', ./watch.sh: line 29: mateconftool-2: command not found, No such schema 'org.gnome.shell.extensions.user-theme', No such schema 'org.cinnamon.theme'... – Ionică Bizău Mar 28 '15 at 19:32
  • I have now commented the mateconftool-2 out from the code. so you should not see this error again. because i did not know which theme engine you use i added the most 3 popular ones. Please copy the script again and replace your existing one. – snapo Mar 30 '15 at 15:13