Skip to content

Commit e6584ed

Browse files
Move cheat sheet to documents directory (#1273)
1 parent 597fd4a commit e6584ed

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

cursorless-talon/src/cheatsheet/cheat_sheet.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ def cursorless_open_instructions():
4343
class Actions:
4444
def cursorless_cheat_sheet_show_html():
4545
"""Show cursorless html cheat sheet"""
46-
# NB: We use the user's home directory instead of temp to make sure that
47-
# Linux snaps work
48-
cheatsheet_out_dir = Path.home() / ".cursorless" / "cheatsheet"
46+
# On Linux browsers installed using snap can't open files in a hidden directory
47+
if app.platform == "linux":
48+
cheatsheet_out_dir = cheatsheet_dir_linux()
49+
cheatsheet_filename = "cursorless-cheatsheet.html"
50+
else:
51+
cheatsheet_out_dir = Path.home() / ".cursorless"
52+
cheatsheet_filename = "cheatsheet.html"
53+
4954
cheatsheet_out_dir.mkdir(parents=True, exist_ok=True)
50-
cheatsheet_out_path = cheatsheet_out_dir / "index.html"
55+
cheatsheet_out_path = cheatsheet_out_dir / cheatsheet_filename
5156
run_rpc_command_and_wait(
5257
"cursorless.showCheatsheet",
5358
{
@@ -66,6 +71,23 @@ def cursorless_cheat_sheet_update_json():
6671
)
6772

6873

74+
def cheatsheet_dir_linux() -> Path:
75+
"""Get cheatsheet directory for Linux"""
76+
try:
77+
# 1. Get users actual document directory
78+
import platformdirs
79+
80+
return Path(platformdirs.user_documents_dir())
81+
except:
82+
# 2. Look for a documents directory in user home
83+
user_documents_dir = Path.home() / "Documents"
84+
if user_documents_dir.is_dir():
85+
return user_documents_dir
86+
87+
# 3. Fall back to user home
88+
return Path.home()
89+
90+
6991
def cursorless_cheat_sheet_get_json():
7092
"""Get cursorless cheat sheet json"""
7193
return {

0 commit comments

Comments
 (0)