6

Many Android apps have an option for light/dark mode (daytime vs. nighttime hours). I find that very useful at times. Is there any such option in Ubuntu 16.04?? It would be very useful for battery consumption and for the late night hours.
Maybe you could add an option for that in the Power Manager icon or directly on the desktop? OR at least for the themes with lite and dark variants, like Vertex or Arc.

4

No, there is no fast way to do this. After changing to dark or light theme applications must be restarted which is probably not what you want.

Otherwise corntab might help. You could create two scripts - first that will enable dark mode and second that will disable it.

EDIT: Steps to create crontab jobs to enable/disable dark mode.

1. Step:
Create ~/.config/gtk-3.0/settings.ini file with following content:

[Settings]
gtk-application-prefer-dark-theme=0

or append gtk-application-prefer-dark-theme=0 line if that file already exists without this line. 0 - dark mode disabled, 1 - dark mode enabled.

2. Step:
Create script dark-mode.sh that will enable/disable dark mode:

#!/bin/sh

action="$1"
test -z "$action" && action=1

if [ "$action" = 1 ]; then  
  SEARCH=gtk-application-prefer-dark-theme=0  
  REPLACE=gtk-application-prefer-dark-theme=1  
else  
  SEARCH=gtk-application-prefer-dark-theme=1  
  REPLACE=gtk-application-prefer-dark-theme=0  
fi

/bin/sed -i 's/'$SEARCH'/'$REPLACE'/g' /home/[YOUR-USERNAME]/.config/gtk-3.0/settings.ini

Replace [YOUR-USERNMAE] with your real user name in above script and make it executable by running chmod +x dark-mode.sh command.

3. Step:
Create crontab jobs by running crontab -e and then append at end following lines:

# Every day at 07:00 disable dark mode
0 7 * * * /bin/sh /home/[YOUR-USERNMAE]/dark-mode.sh 0

# Every day at 21:00 enable dark mode
0 21 * * * /bin/sh /home/[YOUR-USERNMAE]/dark-mode.sh 1

And again replace [YOUR-USERNMAE] with your real user name, save and exit. Now every day at 7:00 dark mode will be disabled and at 21:00 it will be enabled.

This might not be enough, for example if you often turn off/on your PC than you might need adjust script to detect current time and execute it on login to make sure right theme mode is used.

| improve this answer | |
  • Smart solution! Like it. – abu_bua Nov 25 '18 at 19:03
3

There seems to be an app made exactly for this purpose: https://github.com/C2N14/AutomaThemely

Give it a whirl :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.