diff --git a/99-deft.sh.in b/99-deft.sh.in new file mode 100644 index 0000000..f7c5c33 --- /dev/null +++ b/99-deft.sh.in @@ -0,0 +1,10 @@ +# Deft — add the user-local KTextEditor plugin directory to Qt's search path. +# +# Kate/KTextEditor only loads plugins found on QT_PLUGIN_PATH. When Deft is +# installed under a user prefix (the default, ~/.local) rather than a system +# one, that directory is not searched unless it is added here. Plasma sources +# every *.sh in ~/.config/plasma-workspace/env/ at login. +# +# The path below is filled in at install time with the directory the plugins +# were installed into. +export QT_PLUGIN_PATH="@DEFT_PLUGIN_PATH@${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}" diff --git a/CMakeLists.txt b/CMakeLists.txt index b281905..968ae60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,37 @@ find_package(KF6 ${KF_MIN_VERSION} COMPONENTS TextEditor XmlGui CoreAddons I18n) set(KDE_INSTALL_PLUGINDIR "${QT6_INSTALL_PLUGINS}") set(KDE_INSTALL_PLUGINDIR "${QT6_INSTALL_PLUGINS}" CACHE PATH "" FORCE) +# Qt only searches QT_PLUGIN_PATH for plugins. A user-prefix install (the +# default) puts the plugins outside the system search path, so Kate will not +# find them until that directory is added to QT_PLUGIN_PATH. Generate a Plasma +# login environment snippet that does exactly that, and — for a user-local +# install — drop it into ~/.config/plasma-workspace/env/ automatically so the +# lookup path is wired up without a manual step. For a system install the user +# installs it themselves (printed below); packagers usually don't want it. +get_filename_component(DEFT_PLUGIN_PATH + "${CMAKE_INSTALL_PREFIX}/${QT6_INSTALL_PLUGINS}" ABSOLUTE) +configure_file("${CMAKE_SOURCE_DIR}/99-deft.sh.in" + "${CMAKE_BINARY_DIR}/99-deft.sh" @ONLY) + +# Is the chosen prefix inside the user's home (a personal install)? +string(FIND "${CMAKE_INSTALL_PREFIX}" "$ENV{HOME}" _deft_prefix_in_home) +if(_deft_prefix_in_home EQUAL 0) + set(_deft_plasma_env_dir "$ENV{HOME}/.config/plasma-workspace/env") + install(CODE " + file(MAKE_DIRECTORY \"${_deft_plasma_env_dir}\") + file(INSTALL \"${CMAKE_BINARY_DIR}/99-deft.sh\" + DESTINATION \"${_deft_plasma_env_dir}\") + message(STATUS \"Deft: installed Qt plugin-path snippet to ${_deft_plasma_env_dir}/99-deft.sh\") + message(STATUS \"Deft: log out and back in (or run: export QT_PLUGIN_PATH=\\\"${DEFT_PLUGIN_PATH}:\\\$QT_PLUGIN_PATH\\\") so Kate finds the plugins now.\") + ") +else() + install(CODE " + message(STATUS \"Deft: plugins installed under a system prefix; QT_PLUGIN_PATH already covers it if that prefix is standard.\") + message(STATUS \"Deft: if Kate does not list them, add this to the Qt plugin path: ${DEFT_PLUGIN_PATH}\") + message(STATUS \"Deft: a ready-made login snippet is at ${CMAKE_BINARY_DIR}/99-deft.sh (copy to ~/.config/plasma-workspace/env/).\") + ") +endif() + enable_testing() add_subdirectory(src) diff --git a/README.md b/README.md index fd894f2..a1005f9 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,28 @@ system-wide instead, pass an explicit prefix (and expect to need `root`): cmake --install build --prefix /usr ``` +### Making Kate find a user-local install + +Qt only loads plugins from directories on **`QT_PLUGIN_PATH`**, and that does +*not* include `~/.local` by default — so after a home-directory install Kate +will not list the plugins until that path is on the search list. This is a +one-time, per-user setup step. + +The install **automates it for you**: when the prefix is inside your home, it +writes a login snippet to +`~/.config/plasma-workspace/env/99-deft.sh` that adds the plugin directory to +`QT_PLUGIN_PATH`. Plasma sources it at login, so after the next **log out / log +in** Kate finds the plugins. To use them in the *current* session without +logging out, run the export the installer prints, e.g.: + +```sh +export QT_PLUGIN_PATH="$HOME/.local/lib/x86_64-linux-gnu/qt6/plugins:$QT_PLUGIN_PATH" +``` + +(For a non-Plasma session, put that same line in your shell profile. For a +system-prefix install this step is unnecessary; the installer prints the ready +snippet under the build dir if you still want it.) + Then in Kate: Settings → Configure Kate → Plugins → enable each **`[deft:…]`** plugin you installed. See [The plugins](#the-plugins) below for what each one does and how to drive it.