diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-25 09:53:11 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-25 09:53:11 +0200 |
commit | e9c88090ed49fbb9e4ae7ec5141ab0714509dc39 (patch) | |
tree | 86791a92a08de80a922f21ef5277abde76914f26 /src | |
parent | c85cd297b0453e8889f8633e4cfe6161ae469d56 (diff) |
Load mpris mpv script if its installed
Diffstat (limited to 'src')
-rw-r--r-- | src/VideoPlayer.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index 5d2bf3c..8020c3c 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -116,6 +116,16 @@ namespace QuickMedia { remove(tmp_chapters_filepath); } + static Path get_config_dir_xdg() { + Path path; + const char *xdg_config_home_p = getenv("XDG_CONFIG_HOME"); + if(xdg_config_home_p) + path = xdg_config_home_p; + else + path = get_home_dir().join(".config"); + return path; + } + VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, const char *audio_path, sf::WindowHandle _parent_window, const std::string &title, const std::string &start_time) { parent_window = _parent_window; @@ -180,6 +190,11 @@ namespace QuickMedia { else args.push_back(ytdl_format.c_str()); + std::string mpris_arg; + Path mpris_path = get_config_dir_xdg().join("mpv").join("scripts").join("mpris.so"); + if(get_file_type(mpris_path) == FileType::REGULAR) + mpris_arg = "--script=" + mpris_path.data; + if(!use_system_mpv_config) { args.insert(args.end(), { "--no-config", @@ -187,6 +202,9 @@ namespace QuickMedia { "--vo=gpu,vdpau,x11", "--hwdec=auto" }); + + if(!mpris_arg.empty()) + args.push_back(mpris_arg.c_str()); } std::string force_media_title_arg; |