@@ -43,11 +43,16 @@ def cursorless_open_instructions():
43
43
class Actions :
44
44
def cursorless_cheat_sheet_show_html ():
45
45
"""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
+
49
54
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
51
56
run_rpc_command_and_wait (
52
57
"cursorless.showCheatsheet" ,
53
58
{
@@ -66,6 +71,23 @@ def cursorless_cheat_sheet_update_json():
66
71
)
67
72
68
73
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
+
69
91
def cursorless_cheat_sheet_get_json ():
70
92
"""Get cursorless cheat sheet json"""
71
93
return {
0 commit comments