Skip to content

Commit

Permalink
Add PWA launcher for Windows WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
djblue committed Sep 25, 2024
1 parent 2e56a7a commit 0c54c54
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/portal/runtime/browser.cljc
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
(ns ^:no-doc portal.runtime.browser
#?(:clj (:refer-clojure :exclude [random-uuid]))
#?(:clj (:require [clojure.java.browse :refer [browse-url]]
[clojure.string :as str]
[portal.runtime :as rt]
[portal.runtime.fs :as fs]
[portal.runtime.json :as json]
[portal.runtime.jvm.client :as c]
[portal.runtime.shell :as shell])
:cljs (:require [portal.runtime :as rt]
:cljs (:require [clojure.string :as str]
[portal.runtime :as rt]
[portal.runtime.fs :as fs]
[portal.runtime.json :as json]
[portal.runtime.node.client :as c]
[portal.runtime.shell :as shell])
:cljr (:require [portal.runtime :as rt]
:cljr (:require [clojure.string :as str]
[portal.runtime :as rt]
[portal.runtime.clr.client :as c]
[portal.runtime.fs :as fs]
[portal.runtime.json :as json]
[portal.runtime.shell :as shell]))
#?(:cljr (:import [System.Runtime.InteropServices RuntimeInformation OSPlatform])))
#?(:cljr (:import [System.Runtime.InteropServices OSPlatform RuntimeInformation])))

(defmulti -open (comp :launcher :options))

Expand Down Expand Up @@ -70,10 +73,27 @@
:when (and profile app-id)]
{:app-id app-id :profile profile}))))

(defn- get-windows-user []
(str/trim (:out (shell/sh "cmd.exe" "/C" "echo %USERNAME%"))))

(defn- get-app-id-profile-windows [app-name]
(try
(some
(fn [file]
(when (str/ends-with? file (str app-name ".lnk"))
{:app-id (str/replace (fs/basename (fs/dirname file)) "_crx_" "")}))
(fs/file-seq
(fs/join "/mnt/c/Users"
(get-windows-user)
"AppData/Local/Google/Chrome/User Data/Default/Web Applications")))
(catch #?(:cljs :default :default Exception) _)))

(defn- get-app-id-profile
"Returns app-id and profile if portal is installed as `app-name` under any of the browser profiles"
[app-name]
(or (get-app-id-profile-osx app-name) (get-app-id-profile-linux app-name)))
(or (get-app-id-profile-osx app-name)
(get-app-id-profile-linux app-name)
(get-app-id-profile-windows app-name)))

(def pwa
{:name "portal"
Expand Down

0 comments on commit 0c54c54

Please sign in to comment.