aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md19
-rw-r--r--TODO1
-rw-r--r--example-config.json2
-rw-r--r--include/Config.hpp3
-rw-r--r--include/QuickMedia.hpp2
-rw-r--r--include/VideoPlayer.hpp1
-rw-r--r--src/Config.cpp3
-rw-r--r--src/QuickMedia.cpp46
-rw-r--r--src/VideoPlayer.cpp7
-rw-r--r--video_player/src/main.cpp38
10 files changed, 81 insertions, 41 deletions
diff --git a/README.md b/README.md
index 35b30d7..eca4ea7 100644
--- a/README.md
+++ b/README.md
@@ -5,24 +5,7 @@ A rofi inspired native client for web services.
Currently supported web services: `youtube`, `peertube`, `lbry`, `soundcloud`, `nyaa.si`, `manganelo`, `manganelos`, `mangatown`, `mangakatana`, `mangadex`, `onimanga`, `4chan`, `matrix`, `saucenao`, `hotexamples`, `anilist`, `dramacool` and _others_.\
QuickMedia also supports reading local manga and watching local anime, see [local manga](#local-manga) and [local anime](#local-anime)
## Usage
-```
-usage: quickmedia [plugin|] [--no-video] [--upscale-images] [--upscale-images-always] [--dir <directory>] [--instance <instance>] [-e <window>] [--video-max-height <height>]
-OPTIONS:
- plugin|url The plugin to use. Should be either launcher, 4chan, manga, manganelo, manganelos, mangatown, mangakatana, mangadex, onimanga, local-manga, local-anime, youtube, peertube, lbry, soundcloud, nyaa.si, matrix, saucenao, hotexamples, anilist, dramacool, file-manager or stdin. This can also be a youtube url, youtube channel url or a 4chan thread url
- --no-video Only play audio when playing a video. Disabled by default
- --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default
- --upscale-images-always Upscale manga pages using waifu2x-ncnn-vulkan, no matter what the original image resolution is. Disabled by default
- --dir <directory> Set the start directory when using file-manager
- --instance <instance> The instance to use for peertube
- -e <window-id> Embed QuickMedia into another window
- --video-max-height <height> Media plugins will try to select a video source that is this size or smaller
-EXAMPLES:
- quickmedia
- quickmedia --upscale-images-always manganelo
- quickmedia https://www.youtube.com/watch?v=jHg91NVHh3s
- echo -e "hello\nworld" | quickmedia stdin
- tabbed -c -k quickmedia launcher -e
-```
+Run `qm --help` to see the usage options.
## Installation
If you are running arch linux then you can install QuickMedia from aur: [https://aur.archlinux.org/packages/quickmedia-git/](https://aur.archlinux.org/packages/quickmedia-git/), otherwise you will need to run `./install.sh` as root.\
`tar` and curl needs to be installed to run the `install.sh` script.\
diff --git a/TODO b/TODO
index 0263c12..ac377c8 100644
--- a/TODO
+++ b/TODO
@@ -302,3 +302,4 @@ Keep the rooms that we were kicked/banned from so we can still read them and re-
Fix youtube broken without yt-dlp. Unable to download video.
Use different font for chinese, japanese and korean (or maybe only for korean).
Include noto font instead of having to install it. Only require installing it for other noto fonts.
+Press g to start typing text in matrix with /encrypt text.
diff --git a/example-config.json b/example-config.json
index 83858c8..7fcb75d 100644
--- a/example-config.json
+++ b/example-config.json
@@ -152,6 +152,8 @@
"use_system_fonts": false,
// Use system (~/.config/mpv) mpv.conf instead of the one provided by QuickMedia
"use_system_mpv_config": false,
+ // Which mpv profile to use when |use_system_mpv_config| is set to true
+ "system_mpv_profile": "",
// Enable shaders. Only set to false if you have a very slow computer or dont care about graphical effects
// such as rounded corners. Rounded corners can also be disabled with the theme option "rounded_rectangles"
"enable_shaders": true,
diff --git a/include/Config.hpp b/include/Config.hpp
index e737fee..fe210a6 100644
--- a/include/Config.hpp
+++ b/include/Config.hpp
@@ -132,6 +132,7 @@ namespace QuickMedia {
FileManagerConfig file_manager;
bool use_system_fonts = false;
bool use_system_mpv_config = false;
+ std::string system_mpv_profile;
bool enable_shaders = true;
std::string theme = "default";
float scale = 1.0f;
@@ -140,5 +141,5 @@ namespace QuickMedia {
bool low_latency_mode = false;
};
- const Config& get_config();
+ Config& get_config();
} \ No newline at end of file
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 038cf19..c316f5e 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -119,7 +119,7 @@ namespace QuickMedia {
void set_clipboard(const std::string &str);
bool youtube_dl_extract_url(const std::string &url, std::string &video_url, std::string &audio_url);
private:
- void init(mgl::WindowHandle parent_window, std::string &program_path, bool no_dialog);
+ void init(mgl::WindowHandle parent_window, std::string &program_path, bool no_dialog, const std::string &theme);
const char* get_youtube_dl_program_name();
void check_youtube_dl_installed(const std::string &plugin_name);
void load_plugin_by_name(std::vector<Tab> &tabs, int &start_tab_index, FileManagerMimeType fm_mime_type, FileSelectionHandler file_selection_handler, std::string instance);
diff --git a/include/VideoPlayer.hpp b/include/VideoPlayer.hpp
index bea03fc..ea5996a 100644
--- a/include/VideoPlayer.hpp
+++ b/include/VideoPlayer.hpp
@@ -39,6 +39,7 @@ namespace QuickMedia {
mgl::WindowHandle parent_window;
bool no_video = false;
bool use_system_mpv_config = false;
+ std::string system_mpv_profile;
bool use_system_input_config = false; // |use_system_mpv_config| has to be true if this is set to true
bool keep_open = false;
bool resume = false;
diff --git a/src/Config.cpp b/src/Config.cpp
index ecc1fce..64d5019 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -406,6 +406,7 @@ namespace QuickMedia {
get_json_value(json_root, "use_system_fonts", config->use_system_fonts);
get_json_value(json_root, "use_system_mpv_config", config->use_system_mpv_config);
+ get_json_value(json_root, "system_mpv_profile", config->system_mpv_profile);
get_json_value(json_root, "enable_shaders", config->enable_shaders);
get_json_value(json_root, "theme", config->theme);
get_json_value(json_root, "scale", config->scale);
@@ -414,7 +415,7 @@ namespace QuickMedia {
get_json_value(json_root, "low_latency_mode", config->low_latency_mode);
}
- const Config& get_config() {
+ Config& get_config() {
init_config();
return *config;
}
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index b09e09f..037d218 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -339,7 +339,7 @@ namespace QuickMedia {
}
static void usage() {
- fprintf(stderr, "usage: quickmedia [plugin|url] [--no-video] [--upscale-images] [--upscale-images-always] [--dir <directory>] [--instance <instance>] [-e <window>] [--video-max-height <height>]\n");
+ fprintf(stderr, "usage: quickmedia [plugin|url] [--no-video] [--upscale-images] [--upscale-images-always] [--dir <directory>] [--instance <instance>] [-e <window>] [--video-max-height <height>] [--theme <theme>]\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, " plugin|url The plugin to use. Should be either launcher, 4chan, manga, manganelo, manganelos, mangatown, mangakatana, mangadex, onimanga, local-manga, local-anime, youtube, peertube, lbry, soundcloud, nyaa.si, matrix, saucenao, hotexamples, anilist, dramacool, file-manager, stdin, pornhub, spankbang, xvideos or xhamster. This can also be a youtube url, youtube channel url or a 4chan thread url\n");
fprintf(stderr, " --no-video Only play audio when playing a video. Disabled by default\n");
@@ -349,6 +349,7 @@ namespace QuickMedia {
fprintf(stderr, " --instance <instance> The instance to use for peertube\n");
fprintf(stderr, " -e <window-id> Embed QuickMedia into another window\n");
fprintf(stderr, " --video-max-height <height> Media plugins will try to select a video source that is this size or smaller\n");
+ fprintf(stderr, " --theme The theme to use. If this is specified then it overrides the theme selected in the QuickMedia config file. Optional.\n");
fprintf(stderr, "EXAMPLES:\n");
fprintf(stderr, " quickmedia\n");
fprintf(stderr, " quickmedia --upscale-images-always manganelo\n");
@@ -409,6 +410,7 @@ namespace QuickMedia {
std::string program_path = Path(argv[0]).parent().data;
std::string instance;
std::string download_filename;
+ std::string theme;
bool no_dialog = false;
for(int i = 1; i < argc; ++i) {
@@ -523,6 +525,15 @@ namespace QuickMedia {
}
} else if(strcmp(argv[i], "--no-dialog") == 0) {
no_dialog = true;
+ } else if(strcmp(argv[i], "--theme") == 0) {
+ if(i < argc - 1) {
+ theme = argv[i + 1];
+ ++i;
+ } else {
+ fprintf(stderr, "Missing theme after --theme argument\n");
+ usage();
+ return -1;
+ }
} else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
usage();
return 0;
@@ -602,7 +613,7 @@ namespace QuickMedia {
};
no_video = force_no_video;
- init(parent_window, program_path, no_dialog);
+ init(parent_window, program_path, no_dialog, theme);
if(strcmp(plugin_name, "download") == 0) {
if(!url) {
@@ -687,7 +698,7 @@ namespace QuickMedia {
return focused_monitor_center;
}
- void Program::init(mgl::WindowHandle parent_window, std::string &program_path, bool no_dialog) {
+ void Program::init(mgl::WindowHandle parent_window, std::string &program_path, bool no_dialog, const std::string &theme) {
disp = XOpenDisplay(NULL);
if (!disp) {
show_notification("QuickMedia", "Failed to open display to X11 server", Urgency::CRITICAL);
@@ -699,6 +710,9 @@ namespace QuickMedia {
// Initialize config and theme early to prevent possible race condition on initialize
get_config();
+ if(!theme.empty())
+ get_config().theme = theme;
+
get_theme();
mgl::vec2i monitor_size;
@@ -3516,6 +3530,7 @@ namespace QuickMedia {
startup_args.parent_window = window.get_system_handle();
startup_args.no_video = is_audio_only;
startup_args.use_system_mpv_config = get_config().use_system_mpv_config || video_page->is_local();
+ startup_args.system_mpv_profile = get_config().system_mpv_profile;
startup_args.use_system_input_config = video_page->is_local();
startup_args.keep_open = is_matrix && !is_youtube;
startup_args.resume = false;
@@ -7133,6 +7148,17 @@ namespace QuickMedia {
}
};
+ auto start_typing = [&] {
+ RoomExtraData &room_extra_data = matrix->get_room_extra_data(current_room);
+ frame_skip_text_entry = true;
+ chat_input.set_editable(true);
+ if(get_config().matrix.clear_message_on_escape || !room_extra_data.editing_message_id.empty()) {
+ chat_input.set_text("");
+ room_extra_data.editing_message_id.clear();
+ }
+ chat_state = ChatState::TYPING_MESSAGE;
+ };
+
for(size_t i = 0; i < tabs.size(); ++i) {
tabs[i].body->on_top_reached = on_top_reached;
tabs[i].body->on_bottom_reached = on_bottom_reached;
@@ -7279,14 +7305,12 @@ namespace QuickMedia {
}
if(event.key.code == mgl::Keyboard::I && !event.key.control) {
- RoomExtraData &room_extra_data = matrix->get_room_extra_data(current_room);
- frame_skip_text_entry = true;
- chat_input.set_editable(true);
- if(get_config().matrix.clear_message_on_escape || !room_extra_data.editing_message_id.empty()) {
- chat_input.set_text("");
- room_extra_data.editing_message_id.clear();
- }
- chat_state = ChatState::TYPING_MESSAGE;
+ start_typing();
+ }
+
+ if(event.key.code == mgl::Keyboard::G && !event.key.control) {
+ start_typing();
+ chat_input.set_text("/encrypt ");
}
if(event.key.control && event.key.code == mgl::Keyboard::V) {
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index 3aa4eca..0fac7aa 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -256,12 +256,16 @@ namespace QuickMedia {
if(get_file_type(mpris_path) == FileType::REGULAR)
mpris_arg = "--scripts=" + mpris_path.data;
+ std::string profile_arg;
if(startup_args.use_system_mpv_config) {
args.push_back("--config=yes");
args.push_back("--load-scripts=yes");
args.push_back("--osc=yes");
args.push_back(input_conf_file.c_str());
args.push_back(ytdl_hook_file.c_str());
+
+ if(!startup_args.system_mpv_profile.empty())
+ profile_arg = "--profile=" + startup_args.system_mpv_profile;
} else {
args.insert(args.end(), {
config_dir.c_str(),
@@ -272,6 +276,9 @@ namespace QuickMedia {
args.push_back(mpris_arg.c_str());
}
+ if(!profile_arg.empty())
+ args.push_back(profile_arg.c_str());
+
std::string force_media_title_arg;
if(!startup_args.title.empty()) {
force_media_title_arg = "--force-media-title=" + startup_args.title;
diff --git a/video_player/src/main.cpp b/video_player/src/main.cpp
index e2a8629..15092d9 100644
--- a/video_player/src/main.cpp
+++ b/video_player/src/main.cpp
@@ -307,21 +307,27 @@ static bool string_looks_like_double(const char *str, size_t size) {
return true;
}
-static void mpv_set_before_init_options(mpv_handle *mpv_ctx, const Args &args) {
+static void set_mpv_properties(mpv_handle *mpv_ctx, const MpvProperty &property, bool is_string_property) {
long value_long = 0;
double value_double = 0;
+ if(!is_string_property && string_looks_like_int(property.value.c_str(), property.value.size()) && string_to_long(property.value.c_str(), value_long))
+ check_error(mpv_set_option(mpv_ctx, property.key.c_str(), MPV_FORMAT_INT64, &value_long), property.key.c_str());
+ else if(!is_string_property && string_looks_like_double(property.value.c_str(), property.value.size()) && string_to_double(property.value.c_str(), value_double))
+ check_error(mpv_set_option(mpv_ctx, property.key.c_str(), MPV_FORMAT_DOUBLE, &value_double), property.key.c_str());
+ else
+ check_error(mpv_set_option_string(mpv_ctx, property.key.c_str(), property.value.c_str()), property.key.c_str());
+}
- std::set<std::string> known_string_properties = { "start", "force-media-title" };
+static void mpv_set_before_init_options(mpv_handle *mpv_ctx, const Args &args) {
+ const std::set<std::string> known_string_properties = { "start", "force-media-title" };
+ const std::set<std::string> properties_to_ignore = { "profile" };
for(const MpvProperty &property : args.mpv_properties) {
- const bool is_string_property = known_string_properties.find(property.key) != known_string_properties.end();
+ if(properties_to_ignore.find(property.key) != properties_to_ignore.end())
+ continue;
- if(!is_string_property && string_looks_like_int(property.value.c_str(), property.value.size()) && string_to_long(property.value.c_str(), value_long))
- check_error(mpv_set_option(mpv_ctx, property.key.c_str(), MPV_FORMAT_INT64, &value_long), property.key.c_str());
- else if(!is_string_property && string_looks_like_double(property.value.c_str(), property.value.size()) && string_to_double(property.value.c_str(), value_double))
- check_error(mpv_set_option(mpv_ctx, property.key.c_str(), MPV_FORMAT_DOUBLE, &value_double), property.key.c_str());
- else
- check_error(mpv_set_option_string(mpv_ctx, property.key.c_str(), property.value.c_str()), property.key.c_str());
+ const bool is_string_property = known_string_properties.find(property.key) != known_string_properties.end();
+ set_mpv_properties(mpv_ctx, property, is_string_property);
}
if(args.audio_file) {
@@ -341,6 +347,19 @@ static void mpv_set_before_init_options(mpv_handle *mpv_ctx, const Args &args) {
}
}
+static void mpv_set_after_init_options(mpv_handle *mpv_ctx, const Args &args) {
+ const std::set<std::string> known_string_properties = { "profile" };
+ const std::set<std::string> properties_to_include = { "profile" };
+
+ for(const MpvProperty &property : args.mpv_properties) {
+ if(properties_to_include.find(property.key) == properties_to_include.end())
+ continue;
+
+ const bool is_string_property = known_string_properties.find(property.key) != known_string_properties.end();
+ set_mpv_properties(mpv_ctx, property, is_string_property);
+ }
+}
+
#define READ_END 0
#define WRITE_END 1
@@ -630,6 +649,7 @@ int main(int argc, char **argv) {
mpv_set_before_init_options(mpv_ctx, args);
check_error(mpv_initialize(mpv_ctx), "mpv_initialize");
+ mpv_set_after_init_options(mpv_ctx, args);
check_error(mpv_stream_cb_add_ro(mpv_ctx, "qm-yt", nullptr, open_fn), "mpv_stream_cb_add_ro");
check_error(mpv_observe_property(mpv_ctx, 0, "idle-active", MPV_FORMAT_FLAG), "observe idle-active");