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

Python Pypresence better integration #15

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

StratusFearMe21
Copy link

Hi! It's difficult to get two languages to work together in harmony but I think I have a solution that would allow more people to use this plugin. I was having a problem where your plugin would clog up discord by opening too many instances of python at once and not closing them properly. But my solution allows for python to only be opened once, and then closed only when mpv is finished. It makes lua write to a plain text file in /dev/shm (A linux directory that writes directly to RAM) and then have python read that file every 4 seconds (to avoid asyncio problems) and update discord accordingly. At the moment my implementation only works with Linux because /dev/shm doesn't exist in Windows. But that directory should be able to be easily replaced by a variable in the config file (I don't know how those work yet so I couldn't implement it).

@@ -277,4 +282,5 @@ mp.add_key_binding(o.key_toggle, "active-toggle", function()
{repeatable=false})

-- run `main` function
io.popen('python3 "/media/isaac/Games/Home/isaac/.config/mpv/scripts/mpv-discordRPC/python-pypresence.py" &')
Copy link
Owner

Choose a reason for hiding this comment

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

Please don't use hard coded file path.
just use python instead of python3 explicitly

Copy link
Author

Choose a reason for hiding this comment

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

When I used python instead of python3 it gave me errors about pypresense not existing, and when I installed it with pip it gave me invalid syntax errors. I guess that could just be a Linux thing

mpv-discordRPC/main.lua Outdated Show resolved Hide resolved
mpv-discordRPC/main.lua Outdated Show resolved Hide resolved
mpv-discordRPC/python-pypresence.py Outdated Show resolved Hide resolved
Copy link
Owner

@cniw cniw left a comment

Choose a reason for hiding this comment

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

0ea5638 this is a new feature you shouldn't remove it, this #14

@StratusFearMe21
Copy link
Author

sorry, I was editing an outdated version. Should be fixed now. I also changed the filenames.

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