为了庆祝愚人节,我想要一个超级通知机制。
是否可以将我的 Unity Launcher 改造成 LED 追逐器?像这样:
答案1
使用 Unity Python API,我们可以循环设置所有收藏夹图标的紧急程度属性:
#!/usr/bin/env python3
from gi.repository import Unity, GObject
launchers = Unity.LauncherFavorites.get_default().enumerate_ids()
i = -1
increment = 1
def set_urgency():
global i
global increment
if i == len(launchers) - 1:
increment = -1
elif i == 0:
increment = 1
i = i + increment
launcher = Unity.LauncherEntry.get_for_desktop_id(launchers[i])
urgent = launcher.get_property("urgent")
launcher.set_property("urgent", not urgent)
return True
GObject.timeout_add(100, set_urgency)
GObject.MainLoop().run()