Ubuntu Quiet Hours: How to Set Up Do Not Disturb
In this article
Ubuntu does not have a built-in “quiet hours” feature that automatically silences notifications on a schedule, but you can achieve the same result using the Do Not Disturb toggle in the notification centre or by scheduling it with a small script and cron. The simplest approach is to enable Do Not Disturb manually when you need focus time; for automatic quiet hours, you can use a scheduled command that toggles the setting. This guide covers both methods on Ubuntu 22.04 and later with GNOME, which is the default desktop. Steps may differ slightly if you use a different desktop environment or Ubuntu version.
What You'll Need
- A computer running Ubuntu with the GNOME desktop (the default for Ubuntu Desktop).
- Access to a terminal (press Ctrl+Alt+T to open one).
- Basic familiarity with editing a file and running commands.
- Optional: a text editor such as Gedit or Nano (Nano is preinstalled).
Step-by-Step
- Check your desktop environment. Open a terminal and run
echo $XDG_CURRENT_DESKTOP. If it returnsubuntu:GNOMEorGNOME, the following steps apply. If it returns something else (e.g., KDE, XFCE), the notification settings will be in a different place; look for a “Do Not Disturb” or “Notifications” section in your system settings. - Enable Do Not Disturb manually. Click the clock at the top centre of the screen to open the notification/calendar drop-down. You should see a toggle labelled “Do Not Disturb”. Click it to turn it on. Notifications will be silenced until you turn it off. This is the quickest way to get quiet hours right now.
- Verify the toggle works. With Do Not Disturb on, trigger a test notification (for example, send yourself an email or use the
notify-sendcommand in a terminal:notify-send "Test" "This should not appear"). The notification should not pop up. Turn the toggle off and run the command again to confirm it appears. - Set up automatic quiet hours with a script. If you want quiet hours to turn on and off at set times, you can create a script that toggles the setting. First, find the current status: run
gsettings get org.gnome.desktop.notifications show-banners. It returnstrue(banners on) orfalse(banners off, i.e., Do Not Disturb on). To turn Do Not Disturb on, rungsettings set org.gnome.desktop.notifications show-banners false. To turn it off, usetrue. - Create two small scripts. In your home directory, create a file called
quiet-on.shwith the linegsettings set org.gnome.desktop.notifications show-banners false, and another calledquiet-off.shwithgsettings set org.gnome.desktop.notifications show-banners true. Make them executable:chmod +x quiet-on.sh quiet-off.sh. - Schedule the scripts with cron. Open your crontab with
crontab -e. Add lines to run the scripts at your desired times. For example, to enable quiet hours at 10:00 PM and disable at 7:00 AM every day, add:0 22 * * * /home/yourusername/quiet-on.sh 0 7 * * * /home/yourusername/quiet-off.sh
Replaceyourusernamewith your actual username. Save and exit the editor. Cron will run these commands automatically. - Test the schedule. You can temporarily set the times to a minute or two in the future to confirm the scripts run. Check the notification toggle after the time passes. If it does not change, see Troubleshooting below.
- Alternative: use a GNOME extension. Some third-party GNOME extensions offer scheduled Do Not Disturb, but they are not officially supported and may break with updates. For a reliable solution, stick with the manual toggle or the cron method.
Common Mistakes
- Using the wrong settings key. The key
org.gnome.desktop.notifications show-bannerscontrols banner notifications. Other notification types (e.g., sounds) may have separate keys. The Do Not Disturb toggle in the UI typically affects banners and pop-ups; it does not silence all system sounds. - Forgetting to make scripts executable. If cron cannot execute the script, nothing happens. Always run
chmod +xon your scripts. - Using relative paths in cron. Cron runs with a minimal environment. Use absolute paths (e.g.,
/home/username/quiet-on.sh) in your crontab entries. - Assuming quiet hours block all notifications. Do Not Disturb in GNOME suppresses banner notifications, but some applications (like certain chat apps) may still play sounds or show their own pop-ups. Check individual app settings if you need complete silence.
- Editing crontab without saving. In Nano, press Ctrl+O to save and Ctrl+X to exit. If you exit without saving, the schedule won't be applied.
Tips
- You can also toggle Do Not Disturb quickly with the keyboard shortcut Super+V (opens the notification list) and then clicking the toggle, but this varies by version.
- If you use multiple users on the same machine, the gsettings command applies only to the current user. Each user needs their own cron job or manual toggle.
- Consider using
systemdtimers instead of cron for more flexibility, but cron is simpler for most users. - To check the current status at any time, run
gsettings get org.gnome.desktop.notifications show-banners. - If you want to silence notifications but still see them in the notification list, Do Not Disturb does that: banners are hidden, but they accumulate in the list until you clear them.
Troubleshooting
If the manual toggle does not silence notifications, first check that the application sending notifications respects the system setting. Some apps have their own notification settings. Also, ensure you are toggling the correct switch: the Do Not Disturb toggle is in the notification drop-down, not in Settings.
If the cron job does not run, check that the script is executable and that the path is correct. You can test the script manually by running it in a terminal. Also, verify that cron is running: systemctl status cron. If it is not active, start it with sudo systemctl start cron and enable it with sudo systemctl enable cron.
If the gsettings command fails with “No such schema”, ensure you are running it as the logged-in user (not with sudo) and that the GNOME desktop is active. If you are using a different desktop environment, the schema may not exist.
If notifications still appear despite Do Not Disturb being on, check if the app uses its own notification system (e.g., some Electron apps). In that case, look for a setting within the app to disable notifications or set quiet hours.
Frequently Asked Questions
Does Ubuntu have a built-in quiet hours feature?
No, Ubuntu's GNOME desktop does not have a scheduled quiet hours feature out of the box. You can use the Do Not Disturb toggle manually or automate it with cron and gsettings.
Can I schedule quiet hours without using the terminal?
Not with standard Ubuntu settings. You would need a third-party application or GNOME extension, which may not be officially supported. The terminal method is the most reliable.
Will Do Not Disturb block all sounds?
No, it suppresses banner notifications. System sounds and application-specific sounds may still play. Check individual app settings for complete silence.
Does this work on Ubuntu 20.04?
Yes, the gsettings key and Do Not Disturb toggle exist in GNOME on Ubuntu 20.04, though the exact location of the toggle may differ slightly.
What if I use KDE or XFCE?
The steps are different. Look for “Do Not Disturb” or “Notifications” in your system settings. The gsettings command is specific to GNOME.
Can I set different quiet hours for weekdays and weekends?
Yes, with cron you can specify different schedules. For example, use 0 22 * * 1-5 for weekdays and 0 23 * * 6,0 for weekends.