Recent

Author Topic: popupnotifier and Qt5  (Read 5527 times)

linuxer

  • Jr. Member
  • **
  • Posts: 50
  • Systemd kills Linux Freedom Move to Artix Linux
    • Linuxer
popupnotifier and Qt5
« on: November 05, 2020, 11:41:59 pm »
Hi,

I tried to build and run one of my projects, from GTK2 to Qt5 LCLWidgetType, and I am facing troubles with popupnotifiers, either not showing, or showing and freeze on screen, or showing and closing unexpectedly.

I am using FPC 3.3.1, on Linux.

Any help, in this regard, will be appreciated.

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: popupnotifier and Qt5
« Reply #1 on: November 06, 2020, 01:47:02 am »
You don't mention what OS you are using, but tag line might indicate Linux.

libnotify does a much nicer job on Linux than popupnotify.  I have a unit that decides, depending on OS, to use either TPopupNotify or libnotify.  Works fine on Linux, Windows and Mac. Does need multithreading ....

notifier.pas in project listed below.

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

linuxer

  • Jr. Member
  • **
  • Posts: 50
  • Systemd kills Linux Freedom Move to Artix Linux
    • Linuxer
Re: popupnotifier and Qt5
« Reply #2 on: November 06, 2020, 10:19:07 am »
Thanks for your response,

I use Linux as it is stipulated on both my post and my tagline, so it is Artix Linux.

Will check libnotify and notifier.pas, but was considering an easier way, if exists, though.

Regards

linuxer

  • Jr. Member
  • **
  • Posts: 50
  • Systemd kills Linux Freedom Move to Artix Linux
    • Linuxer
Re: popupnotifier and Qt5
« Reply #3 on: November 06, 2020, 06:28:32 pm »
Thanks for sharing.  :)

Works ootb in all current Linux DEs.

Regards

linuxer

  • Jr. Member
  • **
  • Posts: 50
  • Systemd kills Linux Freedom Move to Artix Linux
    • Linuxer
Re: popupnotifier and Qt5
« Reply #4 on: February 19, 2021, 10:15:21 am »
Hi dbannon,

Gnome polkit (and pkexec) delete environment variables DISPLAY and XAUTHORITY that are needed for X access and notify-send fails, so it cannot access the display, therefor, no notifications are been delivered to the user.

My app, needs privileges to run on root level, so how can I implement it to solve the above issue?

I start my app as follows

Code: [Select]
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY QT_QPA_PLATFORM=xcb QT_STYLE_OVERRIDE=kvantum <command> 
Regards
« Last Edit: February 19, 2021, 10:51:03 am by linuxer »

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: popupnotifier and Qt5
« Reply #5 on: February 19, 2021, 12:04:58 pm »
Hmm, it looks to me like you are seeking to do something that the designers of pkexec have specifically set out to ensure you cannot do -

Quote
... pkexec will not allow you to run X11 applications
       as another user since the $DISPLAY and $XAUTHORITY environment
       variables are not set. 

My guess is you could find a specific way around that (*) but it would not be very reliable and may not work on a DE other than the one you tested it on for example. Because you are relying on libnotify and trying to fool it, any change, internally, to libnotify would break what you are doing. 

(*) - I'd start by leaving a semaphore file somewhere containing DISPLAY, reading that when your app starts up and trying to poke it into the env. But, honestly, its a bad way to do things. 

Actually, what I would consider doing is having a 'server' running in userspace that the root app can communicate with, then the userspace app is in charge of triggering the notification, and, perhaps, do any other user interaction necessary.

Or, do it the official way, dbus. Thats what the Gnome devs would tell you do. They like lots and lots of code....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

linuxer

  • Jr. Member
  • **
  • Posts: 50
  • Systemd kills Linux Freedom Move to Artix Linux
    • Linuxer
Re: popupnotifier and Qt5
« Reply #6 on: February 19, 2021, 01:06:00 pm »
I agree with all your points.

Therefore, my best shot would be by utilizing DBUS stuff (sh@t), but on this case, I will check.


Kind regards

Linuxer
« Last Edit: February 19, 2021, 01:12:45 pm by linuxer »

linuxer

  • Jr. Member
  • **
  • Posts: 50
  • Systemd kills Linux Freedom Move to Artix Linux
    • Linuxer
Re: popupnotifier and Qt5
« Reply #7 on: February 19, 2021, 03:16:58 pm »
Case solved, with notify-osd, w/o any need for dbus workaround

I just have to probably adjust the notifications position, and time, but it does the job

varianus

  • New Member
  • *
  • Posts: 22
Re: popupnotifier and Qt5
« Reply #8 on: February 22, 2021, 02:06:52 pm »
Some years ago I've written this class that directly call DBUS notification api to avoid dependencies on libnotify.
It's the same thing done internally from libnotify library.

https://github.com/varianus/ovoplayer/blob/master/src/platform/unix/notification.pas


linuxer

  • Jr. Member
  • **
  • Posts: 50
  • Systemd kills Linux Freedom Move to Artix Linux
    • Linuxer
Re: popupnotifier and Qt5
« Reply #9 on: February 22, 2021, 07:45:41 pm »
Thanks, I will try it!

 

TinyPortal © 2005-2018