Skip to content

Conversation

@jonmchan
Copy link

@jonmchan jonmchan commented Jul 5, 2024

Implemented eventcmd functionality. Please note new configuration options:

# events that should fire the event_command (comma separated);
# current possible events are:
# userlogin,usergetstations,stationfetchplaylist,songstart,songfinish
#
# example usage: 
# subscribed_events = songstart,songfinish
subscribed_events = songstart,songfinish

# you can pass variable substitution to event_command to replace variable with the actual item.
# Variables supported: $artist, $album, $song, and $station
event_command = C:\Users\Jonathan\bin\wsl-notify-send.exe --appId "Pianobar" --category "$station" "$artist `n$album `n$song"

Please also note, I am NOT a regular C/C++ developer. I haven't touched C since I was in school over 10 years ago. The code in here is very hacky and may need a rewrite. This should be at least a good starting point to implement this. I did test this and it works with making a popup notification toaster like I wanted with the wsl-notify-send application.

image

@jonmchan
Copy link
Author

jonmchan commented Jul 5, 2024

Addresses #40.

# subscribed_events = songstart,songfinish
subscribed_events = songstart,songfinish

# you can pass variable substitution to event_command to get the current songs.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deviates significantly from the upstream implementation which sends (significantly more) metadata to the eventcmd via stdin. As written I think a handler would have to implement support for both styles.

Copy link
Author

@jonmchan jonmchan Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review.

3 thoughts come to mind:

  1. Without the availability of fork() on Windows, is there a better alternative than CreateProcess? Should we be trying to reproduce sending the data via stdin using CreateProcess? Does Windows applications/scripts that would be launched from event_command have as part of their regular design patterns to be reading from stdin or is that more of a *nix design pattern?

  2. Stepping away from the implementation details, I would be interested in understanding the metadata requirements. Would there be limitations in passing these to the event_command as arguments such as argument length limits? Is it just the issue that all the metadata fields has not been implemented in the variable substitution parser or is there a fundamental issue with implementing it this way that necessitates for this to be implemented via stdin?

  3. How much do we care to maintain compliance with the upstream project? As I worked on this feature, I noted that the codebases have significantly diverged with parts of code and library being different such as the removal of libcurl for WinHTTP library and DirectShow player instead of original player. Is there interest to maintain config file parity between this port and the original?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PowerShell/PowerShell#9497
https://stackoverflow.com/questions/6979747/read-stdin-stream-in-a-batch-file

I didn't dive into it too deeply, but powershell and batch files seem to have limitations with reading from stdin. It would be necessary to utilize python or other non-native scripting language to process from stdin.

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

Successfully merging this pull request may close these issues.

2 participants