From e9c88090ed49fbb9e4ae7ec5141ab0714509dc39 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 25 Oct 2021 09:53:11 +0200 Subject: Load mpris mpv script if its installed --- src/VideoPlayer.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/VideoPlayer.cpp') 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; -- cgit v1.2.3