diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/QuickMedia.cpp | 23 | ||||
-rw-r--r-- | src/plugins/Fourchan.cpp | 4 |
2 files changed, 16 insertions, 11 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index f878497..750ea3c 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -56,12 +56,17 @@ namespace QuickMedia { if (!disp) throw std::runtime_error("Failed to open display to X11 server"); + resources_root = "../../../"; + if(get_file_type("/usr/share/quickmedia/") == FileType::DIRECTORY) { + resources_root = "/usr/share/quickmedia/"; + } + window.setVerticalSyncEnabled(true); - if(!font.loadFromFile("../../../fonts/Lato-Regular.ttf")) { + if(!font.loadFromFile(resources_root + "fonts/Lato-Regular.ttf")) { fprintf(stderr, "Failed to load font: Lato-Regular.ttf\n"); abort(); } - if(!bold_font.loadFromFile("../../../fonts/Lato-Bold.ttf")) { + if(!bold_font.loadFromFile(resources_root + "fonts/Lato-Bold.ttf")) { fprintf(stderr, "Failed to load font: Lato-Bold.ttf\n"); abort(); } @@ -141,22 +146,22 @@ namespace QuickMedia { if(!current_plugin) { if(strcmp(argv[i], "manganelo") == 0) { current_plugin = new Manganelo(); - plugin_logo_path = "../../../images/manganelo_logo.png"; + plugin_logo_path = resources_root + "images/manganelo_logo.png"; } else if(strcmp(argv[i], "mangatown") == 0) { current_plugin = new Mangatown(); - plugin_logo_path = "../../../images/mangatown_logo.png"; + plugin_logo_path = resources_root + "images/mangatown_logo.png"; } else if(strcmp(argv[i], "mangadex") == 0) { current_plugin = new Mangadex(); - plugin_logo_path = "../../../images/mangadex_logo.png"; + plugin_logo_path = resources_root + "images/mangadex_logo.png"; } else if(strcmp(argv[i], "youtube") == 0) { current_plugin = new Youtube(); - plugin_logo_path = "../../../images/yt_logo_rgb_dark_small.png"; + plugin_logo_path = resources_root + "images/yt_logo_rgb_dark_small.png"; } else if(strcmp(argv[i], "pornhub") == 0) { current_plugin = new Pornhub(); - plugin_logo_path = "../../../images/pornhub_logo.png"; + plugin_logo_path = resources_root + "images/pornhub_logo.png"; } else if(strcmp(argv[i], "4chan") == 0) { - current_plugin = new Fourchan(); - plugin_logo_path = "../../../images/4chan_logo.png"; + current_plugin = new Fourchan(resources_root); + plugin_logo_path = resources_root + "images/4chan_logo.png"; } else if(strcmp(argv[i], "dmenu") == 0) { current_plugin = new Dmenu(); } diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp index 073356b..22a3faf 100644 --- a/src/plugins/Fourchan.cpp +++ b/src/plugins/Fourchan.cpp @@ -12,7 +12,7 @@ static const std::string fourchan_url = "https://a.4cdn.org/"; static const std::string fourchan_image_url = "https://i.4cdn.org/"; namespace QuickMedia { - Fourchan::Fourchan() : ImageBoard("4chan") { + Fourchan::Fourchan(const std::string &resources_root) : ImageBoard("4chan"), resources_root(resources_root) { thread_list_update_thread = std::thread([this]() { BodyItems new_thread_list_items; while(running) { @@ -52,7 +52,7 @@ namespace QuickMedia { return PluginResult::NET_ERR; #else std::string server_response; - if(file_get_content("../../../boards.json", server_response) != 0) { + if(file_get_content(resources_root + "boards.json", server_response) != 0) { fprintf(stderr, "failed to read boards.json\n"); return PluginResult::ERR; } |