How to Automatically Change Gboard’s Theme to Dark Mode at Night

How to Automatically Change Gboard’s Theme to Dark Mode at Night

On the XDA-Developer Forums, one of the most popular reasons why people still love to root their phone is so they can theme their phone however they like. Thanks to Substratum, most System UI elements and many applications can be themed. If a Substratum theme does not exist for your favorite app, then in some cases you can seek out alternative versions of those apps that do offer theme capabilities. Although Google’s keyboard app, Gboard, does offer you the ability to change its theme, many people are disappointed to discover that there’s no way to automatically change the theme based on the time of day. Perhaps you like having the Material Light theme throughout the day, but want to switch to the Material Dark theme at night so you aren’t blinded by its brightness. In that case, here’s a tutorial on how to automatically change Gboard’s theme based on whatever criteria you want.


Gboard Single Color Themes – Currently 17 in Total


Tasker is the automation app that I’m using to accomplish this setup. You’re free to use other free automation apps, but Tasker is the one that I’ve been using for years, so it’s the only one I’m familiar enough with to make scripts such as this one.

As for needing root access, it’s unfortunately the only way to make changing Gboard’s theme seamless and without user intervention. Since Gboard does not offer any sort of intent or shortcut to quickly switch between themes, we need root access so we can modify Gboard’s preference files located in its /data/data folder.


There are two parts to this script. The first involves making a Tasker Profile – a time context which when met will trigger our Tasker Task to change our Gboard theme. The second, as you can guess, is the Tasker Task itself that is called upon when the Profile is activated. I will walk you through a step-by-step instruction in order to make the Tasker Profile, but I will give less detailed instructions on creating the Tasker Task due to it being a bit more advanced. I recommend when you get to the Tasker Task part that you simply import the Task I will link right below.

Download the Gboard Color Change Task from AndroidFileHost

Download the above Tasker Task and save the .tsk.xml file anywhere on your internal storage. Then open up Tasker and tap on the “TASKS” tab up top. Once you’re in the Tasks tab, long-press on “TASKS” until you see an option to “Import.” Tap on Import and look for the .tsk.xml file you saved earlier. Select it to import it. You should now see a Task named “Gboard Color Change” with the Gboard icon. (Note: if you’ve hidden the Gboard icon from your app drawer, then the icon may display as an error. You can safely ignore that though.)

Next, I’ll guide you through creating the Profile that will make use of this Task that we just imported.

  1. Open up Tasker and tap on the + button in the bottom right.
  2. Select the “Time” Context.
  3. For “From” choose the start time when you want the Gboard Dark theme to be active. For “To” choose the end time when you want the Gboard Light theme to start being active. For instance, I chose From 7:00PM To 7:00AM which means my dark theme is active between 7:00PM-7:00AM and the light theme is active between 7:01AM and 6:59PM.
  4. Hit back, and Tasker will ask you to either attach a Task or create a new one. Even though you imported the Gboard Color Change Task, do not select it. Instead, create a New Task.
  5. Name the Profile something descriptive. I named it “Change Gboard Night Theme.”
  6. Once in the Task editing screen, press the + button in the bottom middle to add a new Action.
  7. Choose Variables –> Variable Set. Name: %theme. To: material_dark.
  8. Add another Action. Choose Task –> Perform Task. For Name, hit the magnification glass and now select Gboard Color Change. Under Parameter 1, enter %theme.

Now exit back to Tasker’s main screen. You’ve completed half of the set-up, since now Tasker will trigger at 7:00PM or whatever time you set and change Gboard’s theme to Material Dark. Now we need to complete the second part, so Tasker will change the theme back to Material Light when it hits 7:00AM or whatever time you set.

  1. Long-press on the Task you just created. You should see an option to Add Exit Task. Pick that option.
  2. No need to name the Task, just enter the Task editing screen again.
  3. Add an Action. Variables –> Variable Set. Name: %theme. To: material_light.
  4. Add another Action. Task –> Perform Task. Name: Gboard Color Change. Under Parameter 1, enter %theme.

And you’re done! Tasker will now automatically change Gboard’s theme based on the time of day. Note that if you haven’t yet ever granted Tasker root access, it will ask you to grant it root access the first time this Task runs. You can force it to ask for root access now rather than later by entering the Gboard Color Change Task, long-pressing on Action #2, and then pressing the run key in the bottom left.

Changing to Other Colors, or on Other Contexts

Using my Task, you can change Gboard’s theme to other colors and based on other Contexts, as well. All you have to do is create new Profiles with difference Contexts (such as an Application Context), then add the two Actions (Variable Set and Perform Task) that I’ve defined above. If you want a color other than Material Dark or Material Light, here is a list of all the strings that correspond to the 17 color options that you have:

  • material_dark
  • material_light
  • google_blue_light
  • google_blue_dark
  • color_red
  • color_green
  • color_teal
  • color_blue
  • color_cyan
  • color_deep_purple
  • color_pink
  • color_light_pink
  • color_brown
  • color_blue_grey
  • color_black
  • holo_blue
  • holo_white

Set the %theme variable to one of these strings in order to set Gboard’s theme to that color.

Explanation of how this works

If you’re curious as to how this works, here’s a brief explanation. Using root, I copy the preferences file used by Gboard located in /data/data/ named This preference file is an XML that contains a string called “additional_keyboard_theme” that contains the name of the color variant being used by Gboard. I use the %theme parameter and replace whatever color is already set there, then push the modified file back to Gboard’s /data folder and then kill the Gboard app. Boom – the theme is changed automatically.

That’s it for this tutorial! Follow our tutorials category for more content like this. Thanks, and stay tuned for our next tutorial!

About author

Mishaal Rahman
Mishaal Rahman

I am the former Editor-in-chief of XDA. In addition to breaking news on the Android OS and mobile devices, I used to manage all editorial and reviews content on the Portal.

We are reader supported. External links may earn us a commission.