@@ -43,11 +43,16 @@ def cursorless_open_instructions():
4343class 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+
6991def cursorless_cheat_sheet_get_json ():
7092 """Get cursorless cheat sheet json"""
7193 return {
0 commit comments