Schneegans / Fly-Pie

:pie: Fly-Pie is an innovative marking menu written as a GNOME Shell extension.
http://schneegans.github.io/news/2021/12/02/flypie10
MIT License
1.18k stars 27 forks source link

Custom Sounds Upon Selection #228

Open WMan22 opened 2 years ago

WMan22 commented 2 years ago

The Motivation

Further customization and auditory memorization of swipe locations which is practical, also it would just simply be cool for certain ricing endeavors, which is fun.

The Solution

Essentially, I want to assign 2 sounds to each fly-pie addition, one for hover over, and one for selection, via a .wav or whatever audio type is compatible from a folder to that addition to my custom menu underneath the name, Icon, and Fixed Angle options. Hopefully I can also assign audio to end points on a Favorites option. I would like to be able to assign a different audio file to each end point and to each nested end point.

The Alternatives

I would like to be able to stash these audio files the same way you can stash other items next to that function near the trash for easy re-use and access. I'd like a mute and unmute toggle too for the whole tree so I can enable and disable this feature on a whim without having to edit a brand new fly pie menu that has these functions without the audio enabled.

Schneegans commented 2 years ago

Hi there! Thanks for this idea, it sounds quite funny indeed. I think it's nothing I'll be working on in the foreseeable future, but if anyone wants to implement this, I'll happily accept a pull request!

blipk commented 1 year ago

The possibility to run scripts before or after the menu action is activated would be able to solve this and add a lot of other custom functionality

Schneegans commented 1 year ago

@blipk That would be a neat solution for this (pretty niche) feature request. And indeed, this is already possible! Here is an example of a small python script which lets you execute code whenever an item in Fly-Pie is hovered or selected:

#!/usr/bin/python3

import dbus
import dbus.mainloop.glib
from gi.repository import GLib

def on_hover(menu, item):
    print(f"hovering {item} in menu {menu}")

def on_select(menu, item):
    print(f"selected {item} in menu {menu}")

if __name__ == '__main__':
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

    bus = dbus.SessionBus()
    proxy = bus.get_object('org.gnome.Shell',
                           '/org/gnome/shell/extensions/flypie')

    proxy.connect_to_signal("OnHover", on_hover)
    proxy.connect_to_signal("OnSelect", on_select)

    print("Waiting for events... Press Ctrl+C to abort.")

    loop = GLib.MainLoop()
    loop.run()

This could easily be extended to play sound effects!