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

Launcher dots #8

Open
kitzberger opened this issue Oct 14, 2022 · 20 comments
Open

Launcher dots #8

kitzberger opened this issue Oct 14, 2022 · 20 comments

Comments

@kitzberger
Copy link

Hi @k-kirill,

I guess I need some support to get the dots on the launcher icon to work. You've mentioned in your README this:

If your Anki's desktop file is not named net.ankiweb.Anki.desktop, then please change the application name in the add-on's config.

Where would I find that file? I've just pinned the anki icon to the launcher by right-clicking and then "add to favorites". Did that create that desktop file? Where? ;-)

@k-kirill
Copy link
Owner

To see the Anki app name in GNOME:

  1. Start Anki
  2. Press Alt+F2
  3. Type "lg" and press Enter
  4. Switch to the Windows tab
  5. See the app: line for Anki

To change app name in the add-on:

  1. Start Anki
  2. Open Tools > Add-ons
  3. Select the "anki_libnotify" add-on
  4. Click the Config button
  5. Change the app name to the one from the app: line but without the .desktop extension

@kitzberger
Copy link
Author

@k-kirill, wow, thanks a lot for the walk thru ;-)

Found it:
image

So I set the app_name to anki-ppd_anki but still no dots ;-(

@k-kirill
Copy link
Owner

Did you restart Anki after the change? Do you use the Dash to Dock extension?

@kitzberger
Copy link
Author

Yeah, did a restart after changing the plugins config.

I'm on Ubuntu 22.04 which is coming with Ubuntu Dock 71. According to its description that's a modified version of Dash to Dock.

@k-kirill
Copy link
Owner

What's the number of cards to study you get in Anki Browser for the is:new or is:due search?

@kitzberger
Copy link
Author

That's 38.

The notification popups are working btw.!

@k-kirill
Copy link
Owner

Do you see that badge in the dock for some other applications like Telegram?

@k-kirill
Copy link
Owner

Can you please post the output of this command after starting Anki?

dbus-monitor "type='signal',interface='com.canonical.Unity.LauncherEntry'"

@kitzberger
Copy link
Author

signal time=1665834899.935455 sender=org.freedesktop.DBus -> destination=:1.2486 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.2486"
signal time=1665834899.935483 sender=org.freedesktop.DBus -> destination=:1.2486 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
   string ":1.2486"

@k-kirill
Copy link
Owner

k-kirill commented Oct 15, 2022

Sorry, I meant the following: run the dbus-monitror command first in terminal and then start Anki and then you should see the output in terminal like this

signal time=1665834743.205162 sender=:1.163 -> destination=(null destination) serial=23 path=/; interface=com.canonical.Unity.LauncherEntry; member=Update
   string "application://net.ankiweb.Anki.desktop"
   array [
      dict entry(
         string "count"
         variant             int64 20
      )
      dict entry(
         string "count-visible"
         variant             boolean true
      )
      dict entry(
         string "progress"
         variant             double 0
      )
      dict entry(
         string "progress-visible"
         variant             boolean true
      )

@kitzberger
Copy link
Author

Ah, then it's this here:

   string "application://anki-ppd_anki.desktop"
   array [
      dict entry(
         string "count"
         variant             int64 38
      )
      dict entry(
         string "count-visible"
         variant             boolean true
      )
      dict entry(
         string "progress"
         variant             double 0.530864
      )
      dict entry(
         string "progress-visible"
         variant             boolean true
      )
   ]

I don't have telegram installed.

@kitzberger
Copy link
Author

kitzberger commented Oct 15, 2022

I was able to add a progress bar and the count badge to the app icon via this snippet here: https://wiki.ubuntu.com/Unity/LauncherAPI#Python_Example

image

I've adjusted the script to this here:

from gi.repository import Unity, Gio, GObject, Dbusmenu

loop = GObject.MainLoop()

# Pretend to be evolution for the sake of the example 
launcher = Unity.LauncherEntry.get_for_desktop_id ("anki-ppd_anki.desktop")

# Show a count of 124 on the icon
launcher.set_property("count", 124)
launcher.set_property("count_visible", True)

# Set progress to 42% done 
launcher.set_property("progress", 0.42)
launcher.set_property("progress_visible", True)


# We also want a quicklist 
ql = Dbusmenu.Menuitem.new ()
item1 = Dbusmenu.Menuitem.new ()
item1.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Item 1")
item1.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, True)
item2 = Dbusmenu.Menuitem.new ()
item2.property_set (Dbusmenu.MENUITEM_PROP_LABEL, "Item 2")
item2.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, True)
ql.child_append (item1)
ql.child_append (item2)
launcher.set_property("quicklist", ql) 

def update_urgency():
    if launcher.get_property("urgent"):
        print("Removing urgent flag")
        launcher.set_property("urgent", False)
    else:
        print("setting urgent flag")
        launcher.set_property("urgent", True)
    return True

GObject.timeout_add_seconds(5, update_urgency)

loop.run()

@k-kirill
Copy link
Owner

Nice, but the add-on uses low level DBus API.
Can you please temporarily replace Ubuntu Dock with Dash to Dock to test with it?

@kitzberger
Copy link
Author

Can you please temporarily replace Ubuntu Dock with Dash to Dock to test with it?

I already did that, it's working with both ;-)

This is the same script with Ubtuntu Dock:

image

@k-kirill
Copy link
Owner

k-kirill commented Oct 15, 2022

And Anki add-on does not work with both :( Maybe it's some snap issue like misconfigured dbus interface (for example, no access to the com.canonical.Unity.LauncherEntry interface). I use flatpak version of Anki and do not have any snaps to troubleshoot it :(

@k-kirill
Copy link
Owner

k-kirill commented Oct 15, 2022

Can you please try this solution?
https://forum.snapcraft.io/t/using-com-canonical-unity-launcherentry-dbus-interface/22004
Change the 16th line of __init__.py of the add-on (Tools > Add-ons > select the add-on > View Files) to the following:

     path = "/com/canonical/unity/launcherentry/1"

@kitzberger
Copy link
Author

Here's the output, still no badges on the launcher icon though ;-(

signal time=1665843183.792471 sender=:1.2802 -> destination=(null destination) serial=9 path=/com/canonical/unity/launcherentry/1; interface=com.canonical.Unity.LauncherEntry; member=Update
   string "application://anki-ppd_anki.desktop"
   array [
      dict entry(
         string "count"
         variant             int64 46
      )
      dict entry(
         string "count-visible"
         variant             boolean true
      )
      dict entry(
         string "progress"
         variant             double 0.483146
      )
      dict entry(
         string "progress-visible"
         variant             boolean true
      )
   ]

@k-kirill
Copy link
Owner

It seems like the unity7 plugin is missing in https://github.com/ppd/anki-ppd/blob/master/snap/snapcraft.yaml
Looking at https://snapcraft.io/docs/interface-management, something like that should be able to enable it:

$ sudo snap connect anki-ppd:unity7 :unity7

Please note I have never used snaps as I use openSUSE Tumbleweed

@kitzberger
Copy link
Author

Hm, it seems that this connection could only be made if the snapcraft.yaml would've specified that "plug".

$ sudo snap connect anki-ppd:unity7 :unity7
Error: snap "anki-ppd" has no plug named "unity7"

Damn.

@k-kirill
Copy link
Owner

Okay, let's wait for ppd/anki-ppd#5

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