Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to enable automounting on Sway/Wayland. #215

Closed
johnnynalley opened this issue Jan 25, 2021 · 9 comments
Closed

Unable to enable automounting on Sway/Wayland. #215

johnnynalley opened this issue Jan 25, 2021 · 9 comments

Comments

@johnnynalley
Copy link

I recently switched to Sway/Wayland, and I noticed that the Udiskie status bar applet doesn't allow me to check the boxes. They are unchecked, and checking it closes that dialog but when I go to check it, it's still unchecked.

@coldfix
Copy link
Owner

coldfix commented Jan 25, 2021

Hi,

I can reproduce the behaviour. I added some debug output to check what's going on and it looks that udiskie is enabling/deactivating the automount state internally as expected. It's just that the checkboxes aren't shown - even though they are appropriately created as GtkCheckMenuItem, and the active flag is set correctly.

Looks like a bug somewhere in one of sway/wayland/appindicator to me. The whole trayicon matter seems to be broken on wayland :( see also #199

Edit: nm-applet --indicator seems to have the same problem

Do you have any other program that shows checkboxes in their appindicator menu? If so, we could look there for workarounds.

Best, Thomas

@coldfix
Copy link
Owner

coldfix commented Jan 25, 2021

(Otherwise, I can for now change it to read "Disable" or "Enable", depending on the status)

@johnnynalley
Copy link
Author

johnnynalley commented Jan 26, 2021

Do you have any other program that shows checkboxes in their appindicator menu? If so, we could look there for workarounds.

Unfortunately (Or maybe fortunately...) I do not have any programs that have checkboxes in their appindicator menu.

Looks like a bug somewhere in one of sway/wayland/appindicator to me. The whole trayicon matter seems to be broken on wayland :(

I did notice that nm-applet doesn't even show up on my status bar anymore, even though it is set to autostart ewhen I log onto Sway. Quite odd.

I would like to help as much as possible. Is there anything you would like me to do? Post any debug logs or something?

Edit: My apologies for the late response btw. School's been kicking my ass, got exams all week.

@coldfix
Copy link
Owner

coldfix commented Jan 27, 2021

I did notice that nm-applet doesn't even show up on my status bar anymore, even though it is set to autostart ewhen I log onto Sway. Quite odd.

Did you start with nm-applet --indicator?

I would like to help as much as possible. Is there anything you would like me to do? Post any debug logs or something?

Since the behaviour is the same for both Gtk/AppIndicator3 and Qt/QSystemTrayIcon, I think it's probably an issue with the sway implementation, but I could be wrong. Anyway, you could report the issue to https://github.com/swaywm/sway/issues, they should know where to fix it. I'm currently too lazy to fill out their issue form.

You can show them the following example code:

Gtk/AppIndicator3:

from gi import require_version
require_version('Gtk', '3.0')
require_version('AppIndicator3', '0.1')

import signal
from gi.repository import Gtk
from gi.repository import AppIndicator3


def main():
    indicator = AppIndicator3.Indicator.new(
        'checkbox-test-app', 'dialog-error',
        AppIndicator3.IndicatorCategory.OTHER)
    indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
    indicator.set_menu(build_menu())
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    Gtk.main()


def build_menu():
    check = Gtk.CheckMenuItem('CheckMenuItem')
    check.connect('activate', on_menuitem_check)

    quit = Gtk.MenuItem('Quit')
    quit.connect('activate', lambda _: Gtk.main_quit())

    menu = Gtk.Menu()
    menu.append(check)
    menu.append(quit)
    menu.show_all()
    return menu


def on_menuitem_check(item):
    print("active:", item.get_active())

if __name__ == '__main__':
    main()

and Qt/QSystemTrayIcon:

from PyQt5.QtWidgets import QAction, QApplication, QMenu, QSystemTrayIcon

import signal
import sys


def main():
    app = QApplication(sys.argv)
    style = app.style()
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    trayicon = QSystemTrayIcon(style.standardIcon(style.SP_MessageBoxCritical))
    trayicon.setVisible(True)
    trayicon.setContextMenu(build_menu(trayicon))
    trayicon.show()
    app.exec_()


def build_menu(parent, menu=None):
    check = QAction('CheckMenuItem', parent)
    check.setCheckable(True)
    check.triggered.connect(on_menuitem_check)

    quit = QAction('&Quit', parent)
    quit.setMenuRole(QAction.QuitRole)
    quit.triggered.connect(QApplication.quit)

    menu = menu or QMenu()
    menu.addAction(check)
    menu.addAction(quit)
    return menu


def on_menuitem_check(checked):
    print("active:", checked)


if __name__ == '__main__':
    main()

FWIW, I also checked that it isn't a problem in all menus: checkmenuitems in window menus are shown correctly, as can be verified by inserting the following in the qt main:

    window = QMainWindow()
    build_menu(window, window.menuBar().addMenu('&File'))
    window.show()

Edit: My apologies for the late response btw. School's been kicking my ass, got exams all week.

Not late at all :)

@coldfix
Copy link
Owner

coldfix commented Jan 27, 2021

FYI, I have added a workaround that uses an ImageMenuItem to display checkboxes. If you have installed an icon theme that provides checkbox-checked.png and checkbox.png, it should look okay. Otherwise it will use checkbox icons shipped with udiskie that look a bit sluggish because I created them in a few minutes to avoid copyright issues. Feel free to improve.

@LiterallyJohnny It would nontheless be amazing to report the above minimal example to sway if you can spare the time!

@johnnynalley
Copy link
Author

Yeah, I'll report it to them. I'll try and get it done today if I have time to spare.

Question: The code you provided above, did you make that or is that code from Sway or uDiskie?

@coldfix
Copy link
Owner

coldfix commented Jan 27, 2021

Yeah, I'll report it to them. I'll try and get it done today if I have time to spare.

awesome, thanks! Best also post in this thread here a link to the sway issue.

Question: The code you provided above, did you make that or is that code from Sway or uDiskie?

I created it as a minimal example to show that there is a general problem with checkboxes in tray menus on sway.

@johnnynalley
Copy link
Author

Ah, alright. Sounds good to me, I'll be sure to report the issue soon.

@coldfix
Copy link
Owner

coldfix commented Jul 2, 2021

FYI: I opened Alexays/Waybar#1148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants