Skip to content

Commit

Permalink
use XDG_CACHE_HOME for help file
Browse files Browse the repository at this point in the history
  required for flatpak
  • Loading branch information
dgcampea committed Jun 7, 2021
1 parent 124709b commit a454d6e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion rednotebook/gui/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# -----------------------------------------------------------------------
import os
import platform
import webbrowser

from gi.repository import GdkPixbuf, Gtk
Expand Down Expand Up @@ -408,7 +409,18 @@ def on_help_menu_item_activate(self, widget):
headers=[_("RedNotebook Documentation"), info.version, ""],
options={"toc": 1},
)
utils.show_html_in_browser(html, os.path.join(temp_dir, "help.html"))

# workaround: for flatpak, temp_dir is located at /tmp which is not visible outside sandbox
# but XDG_CACHE_HOME is.
if platform.system() == "Linux":
cache_dir = os.getenv(
"XDG_CACHE_HOME", os.path.join(os.path.expanduser("~"), ".cache")
)
help_file = os.path.join(cache_dir, "help.html")
else:
help_file = os.path.join(temp_dir, "help.html")

utils.show_html_in_browser(html, help_file)

def on_online_help(self, widget):
webbrowser.open(info.answers_url)
Expand Down

0 comments on commit a454d6e

Please sign in to comment.