Score:0

How to add *dynamic* context menu entries in .desktop file (entries generated by script on each context menu reveal)

cn flag

Desktop Environment: Gnome 42.5

I want to add a dynamic list of recently opened files to my VScode .desktop icon. I have a little script that can read the list of recently opened files and folders in the VSCode, and prepare a list of paths from that

RECENT=$(sqlite3 ~/.config/Code/User/globalStorage/state.vscdb \
 "SELECT value FROM ItemTable WHERE key = 'history.recentlyOpenedPathsList'")

DIRS_AND_FILES=$(jq '.[] | group_by(has("fileUri")) | map(.[:3] | map(to_entries[] | .value))' <<<$RECENT)
# gives me a [[3 recent folders], [3 recent files]]

# or those, more straightforward
FOLDERS=$(jq '.[] | map(select(has("fileUri")))[:3] | map(to_entries[] | .value) | .[]' <<<$RECENT)
FILES=$(jq '.[] | map(select(has("fileUri")))[:3] | map(to_entries[] | .value) | .[]' <<<$RECENT)

But how do I add dynamic entries from that? I know how to add static ones, but those require to call the script each time the context menu is run. Is that even possible? Is it possible to add the 2nd level menu entry to the context menu like Recently opened Dirs> [3 items]"?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.