WayfireWM / wayfire

A modular and extensible wayland compositor
https://wayfire.org/
MIT License
2.35k stars 174 forks source link

Enable mapping an action to wayfire events: sound themes #2433

Closed clemencyworld1 closed 3 weeks ago

clemencyworld1 commented 3 weeks ago

Specifically, i will like to play some sounds for some wayfire events like window open, close, minimize, maximize etc and probably other system events like in gnome and some x11 window managers (sawfish). I don't know if such functionality exists, if so i need direction on adding it to my wayfire.ini. If not, i kindly request that such be considered in future release even as a plugin just the way we set keybindings for commands.

Thanks

soreau commented 3 weeks ago

This sounds like it would be a good fit for pywayfire. You can receive events and play sounds however you'd like.

clemencyworld1 commented 3 weeks ago

Please, what's pywayfire and how do i get it? Have not heard about it.

randompersondude commented 3 weeks ago

if ur ok with a bit of scripting, pywayfire would be good i think. its a python binding for the wayfire ipc(it communicates with wayfire to tell it to do things, and it can listen to special events from wayfire, like closing windows or minimising or opening…) just read github.com/wayfireWM/pywayfire

Please, what's pywayfire and how do i get it? Have not heard about it.

soreau commented 3 weeks ago

It's on pypi and can be installed with pip. You can find some examples in the git repo.

clemencyworld1 commented 3 weeks ago

I will try and go through it. But i have only little scripting knowledge.

soreau commented 3 weeks ago

I will try and go through it. But i have only little scripting knowledge.

I put together this python script that can help get you started. It just prints a messages on key events. You would have to open and play a sound file instead. It requires ipc plugin to be enabled.

EDIT: It might be easiest at first, to call an external utility like aplay, with subprocess.Popen() or the like.

randompersondude commented 3 weeks ago

yeah, so

I will try and go through it. But i have only little scripting knowledge.

I put together this python script that can help get you started. It just prints a messages on key events. You would have to open and play a sound file instead. It requires ipc plugin to be enabled.

EDIT: It might be easiest at first, to call an external utility like aplay, with subprocess.Popen() or the like.

Just put import playsound at the start of your code and then replace the print statements with playsound('path_to_sound_file')

soreau commented 3 weeks ago

Since there are event pairs such as open/close, I found it convenient to be able to play sound files in reverse. This way, you get two comparable sounds with only one file. You can do with with play $file reverse from sox.

clemencyworld1 commented 3 weeks ago

Thanks for your replies and assistance. This is what i have done so far:

× This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.

See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification. "

From the instruction above i created a virtual env for python

  1. python3 -m venv ~/venv
  2. source ~/venv/bin/activate
  3. python3 -m pip install . Then got this error "(venv) clemency@debian:~/pywayfire$ python3 -m pip install . Processing /home/clemency/pywayfire Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error

    × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [14 lines of output] error: Multiple top-level packages discovered in a flat-layout: ['path', 'wayfire'].

    To avoid accidental inclusion of unwanted files or directories, setuptools will not proceed with this build.

    If you are trying to create a single distribution with multiple packages on purpose, you should not rely on automatic discovery. Instead, consider the following options:

    1. set up custom discovery (find directive with include or exclude)
    2. use a src-layout
    3. explicitly set py_modules or packages with a list of names

      To find more information, look for "package discovery" on setuptools docs. [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip. "

soreau commented 3 weeks ago

What if you try pip3 install --user .?

clemencyworld1 commented 3 weeks ago

Finally i did "pip install wayfire" and it seem to have installed.

clemencyworld1 commented 3 weeks ago

What if you try pip3 install --user .?

No such option '--user'. I changed "user" to my name

randompersondude commented 3 weeks ago

i believe i see the problem. you say you enabled ipc protocol in the wayfire config manager. however, you also need to have ipc-rules enabled, and that only shows up in the config file. ~/.config/wayfire.ini. u have to add ipc-rules to the end of the plugins line

soreau commented 3 weeks ago

@clemencyworld1 If you need further help, please join #wayfire on IRC, matrix or discord.

ammen99 commented 3 weeks ago

I am closing this issue mostly because the IPC system can do that and I don't plan on adding a plugin for sound, especially since it is so easily doable with IPC. Feel free to ask more questions in the support channels that were mentioned in the previous comment ;)