mirror of
https://github.com/j1g5awi/krunner-vscode.git
synced 2024-11-21 19:19:30 +00:00
Support alternative VSCode installs
Namely VSCode official and VSCodium
This commit is contained in:
parent
3d95df51d3
commit
5165de0380
1 changed files with 29 additions and 16 deletions
|
@ -15,6 +15,13 @@ objpath = "/vscode"
|
||||||
iface = "org.kde.krunner1"
|
iface = "org.kde.krunner1"
|
||||||
|
|
||||||
|
|
||||||
|
VSCODE_DIRS = [
|
||||||
|
"Code",
|
||||||
|
"Code - OSS",
|
||||||
|
"VSCodium"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Match(NamedTuple):
|
class Match(NamedTuple):
|
||||||
data: str
|
data: str
|
||||||
display_text: str
|
display_text: str
|
||||||
|
@ -24,25 +31,31 @@ class Match(NamedTuple):
|
||||||
properties: dict
|
properties: dict
|
||||||
|
|
||||||
|
|
||||||
# TODO Check VSCode or Code - OSS or VSCodium
|
|
||||||
|
|
||||||
# Read path_list from database
|
# Read path_list from database
|
||||||
def get_path_list():
|
def get_path_list():
|
||||||
con = sqlite3.connect(
|
paths = {}
|
||||||
os.path.join(
|
|
||||||
os.environ["HOME"], ".config", "Code - OSS/User/globalStorage/state.vscdb"
|
for vscode_dir in VSCODE_DIRS:
|
||||||
|
state_file = os.path.join(
|
||||||
|
os.environ["HOME"], ".config", vscode_dir, "User/globalStorage/state.vscdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
if not os.path.exists(state_file):
|
||||||
|
continue
|
||||||
|
|
||||||
|
con = sqlite3.connect(state_file)
|
||||||
|
cur = con.cursor()
|
||||||
|
rows = cur.execute(
|
||||||
|
"SELECT value FROM ItemTable WHERE key = 'history.recentlyOpenedPathsList'"
|
||||||
|
)
|
||||||
|
data = json.loads(rows.fetchone()[0])
|
||||||
|
con.close()
|
||||||
|
paths.update(
|
||||||
|
{
|
||||||
|
"~" + path[len(os.environ["HOME"]) :] if os.environ["HOME"] in path else path
|
||||||
|
for path in [i["folderUri"][7:] for i in data["entries"] if "folderUri" in i]
|
||||||
|
}
|
||||||
)
|
)
|
||||||
)
|
|
||||||
cur = con.cursor()
|
|
||||||
rows = cur.execute(
|
|
||||||
"SELECT value FROM ItemTable WHERE key = 'history.recentlyOpenedPathsList'"
|
|
||||||
)
|
|
||||||
data = json.loads(rows.fetchone()[0])
|
|
||||||
con.close()
|
|
||||||
return [
|
|
||||||
"~" + path[len(os.environ["HOME"]) :] if os.environ["HOME"] in path else path
|
|
||||||
for path in [i["folderUri"][7:] for i in data["entries"] if "folderUri" in i]
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class Runner(dbus.service.Object):
|
class Runner(dbus.service.Object):
|
||||||
|
|
Loading…
Reference in a new issue