Q: I use mako for notifications. Is it possible to make it appear over full-screen apps, so I won’t miss any notifications?
A:
Yes, you can configure mako
to show notifications over full-screen applications in Wayland environments, including those managed by sway
. To achieve this, you need to adjust the layer and anchor settings in the mako
configuration.
Here’s how you can do it:
Create or Edit the Mako Configuration File:
mako
uses a configuration file located at$XDG_CONFIG_HOME/mako/config
or~/.config/mako/config
. If the file doesn’t exist, you can create it.Set the Layer and Anchor Properties:
To ensure notifications appear over full-screen apps, you need to set the layer to
overlay
and adjust the anchor properties as needed. Here’s an example configuration:font=FiraSans 10 default-timeout=5000 background-color=#282c34 text-color=#abb2bf border-color=#61afef padding=10 border-size=2 margin=10 layer=overlay [urgency=low] background-color=#3b4252 text-color=#d8dee9 [urgency=normal] background-color=#81a1c1 text-color=#2e3440 [urgency=high] background-color=#bf616a text-color=#2e3440
This configuration sets the notifications to appear on the
overlay
layer at the top-right corner of the screen.Restart Mako:
After updating the configuration file, restart
mako
to apply the changes:pkill mako mako &
Explanation of Key Configuration Options:
layer=overlay
: Ensures notifications are displayed above other windows, including full-screen applications.anchor=top-right
: Positions the notifications at the top-right corner of the screen. You can adjust this totop-left
,bottom-right
, orbottom-left
as per your preference.width
andheight
: Defines the dimensions of the notification window. Settingheight
toauto
ensures the notification height adjusts based on its content.margin
: Adds space around the notification window.border_size
andpadding
: Controls the appearance of the notification window.font
: Sets the font for the notification text.default_timeout
: Determines how long notifications are displayed before disappearing.
This setup ensures that notifications are always visible, even when you have full-screen applications open. Adjust the appearance settings to fit your preferences.
Q: Explain urgency levels for mako.
A: In mako
, urgency levels allow you to style notifications differently based on their importance. There are three predefined urgency levels: low
, normal
, and high
. Each level can have its own set of styling rules, such as background color, border color, text color, timeout duration, and more. This allows you to visually differentiate notifications based on their priority.
Configuring Urgency Levels
You can specify the styling for each urgency level in the mako
configuration file. Here’s an overview of how to set this up:
Locate or Create the Configuration File: The configuration file for
mako
is typically located at$XDG_CONFIG_HOME/mako/config
or~/.config/mako/config
. If it doesn’t exist, you can create it.Define Styles for Each Urgency Level: You can set different properties for each urgency level using
[urgency=low]
,[urgency=normal]
, and[urgency=high]
sections in the configuration file. Here are the properties you can configure:background-color
: The background color of the notification.border-color
: The color of the border around the notification.text-color
: The color of the text in the notification.default-timeout
: How long the notification should be displayed before it disappears.
Here’s an example configuration file that demonstrates how to style notifications based on their urgency levels:
[urgency=low]
background-color=#282c34
border-color=#61afef
text-color=#abb2bf
default-timeout=3000
[urgency=normal]
background-color=#282c34
border-color=#e5c07b
text-color=#abb2bf
default-timeout=5000
[urgency=high]
background-color=#282c34
border-color=#e06c75
text-color=#abb2bf
default-timeout=7000
Explanation of Urgency Levels
Low Urgency:
- Used for less important notifications that do not require immediate attention.
- Typically styled with subtle colors.
- Example:
[urgency=low]
section.
Normal Urgency:
- Default level for regular notifications.
- Used for notifications that are important but not critical.
- Example:
[urgency=normal]
section.
High Urgency:
- Used for critical notifications that require immediate attention.
- Typically styled with more prominent colors to stand out.
- Example:
[urgency=high]
section.
Using Urgency Levels
The application sending the notification will usually specify the urgency level. However, if not explicitly set, mako
will treat the notification as having normal
urgency.
Testing Urgency Levels
To test how notifications with different urgency levels appear, you can use the notify-send
command with the -u
option to set the urgency level:
notify-send -u low "Low Urgency Notification" "This is a low urgency notification."
notify-send -u normal "Normal Urgency Notification" "This is a normal urgency notification."
notify-send -u critical "High Urgency Notification" "This is a high urgency notification."
By setting up and using urgency levels in mako
, you can ensure that more important notifications are visually distinct and immediately recognizable.
Q: Ok. Now I want the system to send me a critical notification for when I have my battery discharge level is at 20% and charge level at 80%. How would I do that with sway in Arch Linux?
A:
To set up critical notifications for battery discharge and charge levels in sway on Arch Linux, you can use a combination of a shell script and systemd
to monitor the battery status and send notifications using notify-send
(or mako
for visual notifications). Here’s a step-by-step guide to achieve this:
Step 1: Install Required Packages
First, make sure you have the required packages installed:
sudo pacman -S acpi libnotify
Step 2: Create a Battery Monitoring Script
Create a script that checks the battery level and sends notifications. Save the script as ~/bin/battery_monitor.sh
(create the ~/bin
directory if it doesn’t exist).
#!/bin/bash
# Define battery levels for notifications
LOW_BATTERY_LEVEL=20
HIGH_BATTERY_LEVEL=80
# Get battery information
BATTERY_INFO=$(acpi -b)
BATTERY_LEVEL=$(echo "$BATTERY_INFO" | grep -oP '[0-9]+(?=%)')
# Check battery status and level
if echo "$BATTERY_INFO" | grep -q Discharging; then
if [ "$BATTERY_LEVEL" -le "$LOW_BATTERY_LEVEL" ]; then
notify-send -u critical "Low Battery" "Battery level is ${BATTERY_LEVEL}%"
fi
elif echo "$BATTERY_INFO" | grep -q Charging; then
if [ "$BATTERY_LEVEL" -ge "$HIGH_BATTERY_LEVEL" ]; then
notify-send -u critical "Battery Charged" "Battery level is ${BATTERY_LEVEL}%"
fi
fi
Make the script executable:
chmod +x ~/bin/battery_monitor.sh
Step 3: Create a Systemd Service
Create a systemd service file to run the battery monitoring script at regular intervals. Save the following as ~/.config/systemd/user/battery_monitor.service
:
[Unit]
Description=Battery Monitor Service
[Service]
ExecStart=%h/bin/battery_monitor.sh
Step 4: Create a Systemd Timer
Create a systemd timer file to specify how often the service should run. Save the following as ~/.config/systemd/user/battery_monitor.timer
:
[Unit]
Description=Run Battery Monitor Script Every 5 Minutes
[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
Persistent=true
[Install]
WantedBy=timers.target
Step 5: Enable and Start the Timer
Enable and start the timer to begin monitoring your battery levels:
systemctl --user enable battery_monitor.timer
systemctl --user start battery_monitor.timer
Step 6: Verify the Setup
You can verify that the timer and service are running correctly with:
systemctl --user status battery_monitor.timer
systemctl --user status battery_monitor.service
Explanation
- The
battery_monitor.sh
script checks the battery level and sends a notification if the battery is discharging and below 20% or charging and above 80%. - The
battery_monitor.service
defines a service to run the script. - The
battery_monitor.timer
sets up a timer to run the service every 5 minutes. - Notifications are sent using
notify-send
, which will be displayed bymako
if it is running.
By following these steps, your system will monitor the battery status and send you critical notifications when the battery level reaches 20% while discharging or 80% while charging.