diff --git a/binding-mri/niko-binding.cpp b/binding-mri/niko-binding.cpp index b9cf332..5b7a47c 100644 --- a/binding-mri/niko-binding.cpp +++ b/binding-mri/niko-binding.cpp @@ -111,9 +111,9 @@ RB_METHOD(nikoPrepare) } #ifdef OS_OSX - journal = std::string(path) + std::string("/_______.app/Contents/MacOS/_______"); + journal = std::string(path) + "/_______.app/Contents/MacOS/_______"; #else - journal = std::string(path) + std::string("_______"); + journal = std::string(path) + "_______"; #endif // Run the binary diff --git a/binding-mri/oneshot-binding.cpp b/binding-mri/oneshot-binding.cpp index fc253a6..b305dc9 100644 --- a/binding-mri/oneshot-binding.cpp +++ b/binding-mri/oneshot-binding.cpp @@ -108,6 +108,9 @@ void oneshotBindingInit() // Constants rb_const_set(module, rb_intern("OS"), rb_str_new2(shState->oneshot().os().c_str())); + #ifdef __linux__ + rb_const_set(module, rb_intern("DE"), rb_str_new2(shState->oneshot().desktopEnv.c_str())); + #endif rb_const_set(module, rb_intern("USER_NAME"), rb_str_new2(shState->oneshot().userName().c_str())); rb_const_set(module, rb_intern("SAVE_PATH"), rb_str_new2(shState->oneshot().savePath().c_str())); rb_const_set(module, rb_intern("DOCS_PATH"), rb_str_new2(shState->oneshot().docsPath().c_str())); diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 4b04a25..6eb054c 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -50,6 +51,8 @@ // KDE settings static std::map defPlugins, defPictures, defColors, defModes; static std::map defBlurs; + // Fallback settings + static std::string fallbackPath; #endif #endif @@ -154,7 +157,10 @@ configFile.close(); } else { Debug() << "FATAL: Cannot find desktop configuration!"; + desktop = "kde_error"; } + } else { + fallbackPath = std::string(getenv("HOME")) + "/Desktop/hint.png"; } } #endif @@ -243,7 +249,7 @@ end: } path = "/Wallpaper/" + nameFix + ".png"; - Debug() << "Setting wallpaper to" << path; + Debug() << "Setting wallpaper to " << path; #ifdef __APPLE__ if (!isCached) { @@ -342,6 +348,10 @@ end: Debug() << "Wallpaper command:" << command.str(); int result = system(command.str().c_str()); Debug() << "Result:" << result; + } else { + std::ifstream srcHint(gameDirStr + path); + std::ofstream dstHint(fallbackPath); + dstHint << srcHint.rdbuf(); } #endif #endif @@ -411,6 +421,60 @@ RB_METHOD(wallpaperReset) } else { xfconf_channel_set_int(bgchannel, optionColorStyle.c_str(), defColorStyle); } + } else if (desktop == "kde") { + std::stringstream command; + command << "qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'string:" << + "var allDesktops = desktops();" << + "var data = {"; + // Plugin, picture, color, mode, blur + for (auto const& x : defPlugins) { + command << "\"" + x.first + "\": {" + << "plugin: \"" << x.second << "\""; + if (defPictures.find(x.first) != defPictures.end()) { + std::string picture = defPictures[x.first]; + boost::replace_all(picture, "\\", "\\\\"); + boost::replace_all(picture, "\"", "\\\""); + boost::replace_all(picture, "'", "\\x27"); + command << ", picture: \"" << picture << "\""; + } + if (defColors.find(x.first) != defColors.end()) { + command << ", color: \"" << defColors[x.first] << "\""; + } + if (defModes.find(x.first) != defModes.end()) { + command << ", mode: \"" << defModes[x.first] << "\""; + } + if (defBlurs.find(x.first) != defBlurs.end() && defBlurs[x.first]) { + command << ", blur: true"; + } + command << "},"; + } + command << "\"no\": {}};" << + "for (var i = 0, l = allDesktops.length; i < l; ++i) {" << + "var d = allDesktops[i];" << + "var dat = data[d.id];" << + "d.wallpaperPlugin = dat.plugin;" << + "d.currentConfigGroup = [\"Wallpaper\", \"org.kde.image\", \"General\"];" << + "if (dat.picture) {" << + "d.writeConfig(\"Image\", dat.picture);" << + "}" << + "if (dat.color) {" << + "d.writeConfig(\"Color\", dat.color);" << + "}" << + "if (dat.mode) {" << + "d.writeConfig(\"FillMode\", dat.mode);" << + "}" << + "if (dat.blur) {" << + "d.writeConfig(\"Blur\", dat.blur);" << + "}" << + "}" << + "'"; + Debug() << "Reset wallpaper command:" << command.str(); + int result = system(command.str().c_str()); + Debug() << "Reset result:" << result; + } else { + if (remove(fallbackPath.c_str()) != 0) { + Debug() << "Failed to delete hint.png!"; + } } #endif #endif diff --git a/src/oneshot.cpp b/src/oneshot.cpp index c31a21a..a667606 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -269,7 +269,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : } // Get documents path - std::string path = std::string(getenv("HOME")) + std::string("/Documents"); + std::string path = std::string(getenv("HOME")) + "/Documents"; p->docsPath = path.c_str(); p->gamePath = path.c_str(); #ifdef OS_OSX