Setting up a desktop notification in Ubuntu after login

The following actions have been tested successfully on Ubuntu 19.04

Setting a desktop notification in Ubuntu after login requires creating a Desktop application following the Freedesktop specifications.
All such applications run as a user must be located in $HOME/.config/autostart

The autostart folder may not exist.
If not :

mkdir -p $HOME/.config/autostart

As an example, this desktop application will be named welcome.desktop

Create this file as follows :


touch $HOME/.config/autostart/welcome.desktop

Add the following lines in it :

cat welcome.desktop

[Desktop Entry]
Type=Application
Exec=/home/$USERNAME/Tools/
welcome_msg.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=myscript
Comment=Startup Script

Create the bash script welcome_msg.sh that will display the notification message :

cat welcome_msg.sh

#!/usr/bin/env bash

notify-send “Good morning ${USERNAME^} !” “Did you check your backups ?”

Make sure that the Exec field in your welcome.desktop file points to your script.

Reboot your Ubuntu machine and log in. Your custom desktop notification will be displayed !

Further readings :

https://cloudkul.com/blog/display-notification-login-ubuntu/

XDG autostart specification

Different ways of autostarting applications in Linux

Desktop Application Autostart Specification

Advertisements

Enabling zenity notifications using cron

Making zenity notifications available using cron as a user is a bit tricky.

Here is the workaround to add to your scripts to make desktop notifications available.


DBUS=$(pgrep -ou $(whoami) mate)
DBUS="$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$DBUS/environ | sed 's/DBUS_SESSION_BUS_ADDRESS=//')"

# Write a notification function
function Notif {
DBUS_SESSION_BUS_ADDRESS="$DBUS" zenity --notification --text="$1" --display=:0
}

# Test this notification function
Notif "your message"

Set up a cron job to test your function using crontab -e and let’s see the magic

Realtek wifi card rtl8723de not detected on Debian Stretch

The HP Pavilion 15-cc507nf notebook comes up with a wifi adapter Realtek rtl8723de not detected after a fresh install of Debian Stretch.
Realtek firmwares are provided by the firmware-realtek package.

After enabling the Stretch-backports, a newer kernel version is available 4.18.0.0 and a newer version of the Firmware-realtek in Stretch backports

This one contains the wifi firmware for rtl8723de : Realtek RTL8723DE firmware (rtlwifi/rtl8723defw.bin)

Just install them and make sure to boot on this latest kernel version. The integrated wifi card is now available for configuration and for use.

XDG: configuration directory ‘/home/fool/.config/newsbeuter’ not accessible, using ‘/home/fool/.newsbeuter’ instead.

On Debian Jessie, I get this error while launching newsbeuter :

“XDG: configuration directory ‘/home/fool/.config/newsbeuter’ not accessible, using ‘/home/fool/.newsbeuter’ instead.”

XDG stands for X Desktop Group and now known as the freedesktop.org project.
More details about XDG

To fix it, here is the workaround :

fool@localhost:~$ cd /home/fool/.config/
fool@localhost:~$ ln -s ~/.newsbeuter/ newsbeuter

Once done, you might have another similar error :

“XDG: data directory ‘/home/fool/.local/share/newsbeuter’ not accessible, using ‘/home/fool/.newsbeuter’ instead.”

To fix it, here is the workaround :

fool@localhost:~$ cd /home/fool/.local/share/
fool@localhost:~$ ln -s ~/.newsbeuter/ newsbeuter

Hope this helps !

Unblocking Bluetooth on Debian

If you find yourself with Bluetooth blocked or disabled, use the rfkill command to reset the Bluetooth fonctionality.
rfkill package must be installed on your system to run the following commands below :

rfkill list
0: hp-wifi: Wireless LAN
Soft blocked: yes
Hard blocked: no
1: hp-bluetooth: Bluetooth
Soft blocked: yes
Hard blocked: no
2: phy0: Wireless LAN
Soft blocked: yes
Hard blocked: no

rfkill unblock 1

rfkill list
0: hp-wifi: Wireless LAN
Soft blocked: no
Hard blocked: no
1: hp-bluetooth: Bluetooth
Soft blocked: no
Hard blocked: no
2: phy0: Wireless LAN
Soft blocked: yes
Hard blocked: no
3: hci0: Bluetooth
Soft blocked: yes
Hard blocked: no

As a precaution, restart the Bluetooth service as follows :

service bluetooth restart
[ ok ] Stopping bluetooth: rfcomm /usr/sbin/bluetoothd.
[ ok ] Starting bluetooth: bluetoothd rfcomm.

Thanks for this tip here: Cannot enable Bluetooth anymore