Linux Notifications (e.g. like Windows tray balloons)
Posted: Fri Apr 24, 2015 7:11 am
I am wondering if there's an easy way (that doesn't require a ton of code) to display notifications on Linux. A prime example would be Ubuntu has "toast-like" notifications that are usually found on Windows 8 applications. Is there an easy (simple) way of triggering notifications that will work across distributions? It doesn't need to work across all of them although Ubuntu and its derivatives and maybe distributions like Arch. I'm using the following code for throwing balloon notifications on Windows and am curious if the same can be done on Linux with a similar amount of code.
Modified for example.
Modified for example.
Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Structure NOTIFYICONDATA_v6
cbSize.l
hWnd.l
uID.l
uFlags.l
uCallbackMessage.l
hIcon.l
szTip.s{128}
dwState.l
dwStateMask.l
szInfo.s{256}
StructureUnion
uTimeout.l
uVersion.l
EndStructureUnion
szInfoTitle.s{64}
dwInfoFlags.l
guidItem.GUID
hBalloonIcon.l
EndStructure
Procedure.i WindowShowBalloonTip(Window.i, TrayIcon.i, Title.s, Message.s, Timeout.l = 3000)
Protected Result.i = #False, Balloon.NOTIFYICONDATA_v6
If OSVersion() >= #PB_OS_Windows_2000
If IsSysTrayIcon(TrayIcon)
Balloon\hWnd = WindowID(Window)
Balloon\uID = TrayIcon
Balloon\uFlags = #NIF_INFO
Balloon\dwState = #NIS_SHAREDICON
Balloon\szInfoTitle = Title
Balloon\szInfo = Message
Balloon\uTimeout = Timeout
Balloon\dwInfoFlags = #NIIF_NOSOUND | #NIIF_INFO
Balloon\cbSize = SizeOf(NOTIFYICONDATA_v6)
Result = Shell_NotifyIcon_(#NIM_MODIFY, Balloon)
EndIf
EndIf
ProcedureReturn Result
EndProcedure
CompilerElseIf #PB_Compiler_OS = #PB_OS_Linux
; Linux variant
CompilerEndIf