Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions Designs.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,26 @@ var DESIGNS = [
{ id: "river", file: "River.qml", name: "River", clip: true, description: "A painting that comes alive on unlock", tags: ["motion"], boot: true, bootKind: "clip", clipFile: "gruvbox-river.mp4", credit: "@yamzeight", anim: true }
]

var USER = []

// Not listed in the explorer, used for monitors without input.
var HIDDEN = [
{ id: "companion", file: "Companion.qml", name: "Companion", description: "Clock only, for secondary monitors", tags: [] }
]

// Designs found in ~/.config/omarchy/lock-designs, set by Service.qml.
function setUser(list) { USER = list || [] }

function all() { return DESIGNS.concat(USER) }
// Designs found in ~/.config/omarchy/lock-designs live on Service.userDesigns
// and are passed in. Module state here is not shared between importing files
// once the shell's load patch rewrites them, so it must not hold that list.
function all(user) { return DESIGNS.concat(user || []) }

// Lockscreen designs split into two navs: static stylings vs animated ones.
function isAnimated(d) { return !!(d && (d.anim === true || d.clip === true)) }
function stylings() { return all().filter(function(d) { return !isAnimated(d) }) }
function animations() { return all().filter(function(d) { return isAnimated(d) }) }
function stylings(user) { return all(user).filter(function(d) { return !isAnimated(d) }) }
function animations(user) { return all(user).filter(function(d) { return isAnimated(d) }) }

function categories() { return CATEGORIES }

function inCategory(category) {
if (!category || category === "all") return all()
return all().filter(function(d) { return (d.tags || []).indexOf(category) !== -1 })
function inCategory(category, user) {
if (!category || category === "all") return all(user)
return all(user).filter(function(d) { return (d.tags || []).indexOf(category) !== -1 })
}

// Designs with a Plymouth twin in plymouth/<id>/, usable as the boot
Expand All @@ -104,20 +102,20 @@ function bootCapable() {
return DESIGNS.filter(function(d) { return d.boot === true })
}

function byId(id) {
var list = all().concat(HIDDEN)
function byId(id, user) {
var list = all(user).concat(HIDDEN)
for (var i = 0; i < list.length; i++) if (list[i].id === id) return list[i]
return null
}

function indexOf(id) {
var list = all()
function indexOf(id, user) {
var list = all(user)
for (var i = 0; i < list.length; i++) if (list[i].id === id) return i
return -1
}

function resolve(id) {
return byId(id) || byId(DEFAULT_ID) || DESIGNS[0]
function resolve(id, user) {
return byId(id, user) || byId(DEFAULT_ID) || DESIGNS[0]
}

function fromUserFile(path) {
Expand Down
1 change: 1 addition & 0 deletions Editor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ Item {
anchors.fill: parent
designId: editor.design ? editor.design.id : ""
revision: editor.service ? editor.service.designsRevision : 0
userDesigns: editor.service && editor.service.userDesigns ? editor.service.userDesigns : []
backgroundPath: editor.service ? editor.service.backgroundPath : ""
backgroundVersion: editor.service ? editor.service.backgroundVersion : 0
wallpaperBlur: editor.service && editor.service.wallpaperBlurValue !== undefined ? editor.service.wallpaperBlurValue : -1
Expand Down
55 changes: 30 additions & 25 deletions Explorer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Item {
property var shell: null
property var manifest: null
property var service: null
readonly property var userDesigns: service && service.userDesigns ? service.userDesigns : []

// Omarchy 4.0.3 hands this overlay `service = null`: the service is an
// authentication service (a clone of omarchy.lock) and the host keeps those
Expand Down Expand Up @@ -132,7 +133,7 @@ Item {
readonly property var favoriteIds: service && service.favorites ? service.favorites : []
function isFavorite(id) { return root.favoriteIds.indexOf(id) !== -1 }
function favoriteDesigns() {
return Designs.all().filter(function(d) { return root.favoriteIds.indexOf(d.id) !== -1 })
return Designs.all(root.userDesigns).filter(function(d) { return root.favoriteIds.indexOf(d.id) !== -1 })
}
function matchesSearch(d, words) {
var hay = [d.name, d.id, d.description || ""].concat(d.tags || []).join(" ").toLowerCase()
Expand Down Expand Up @@ -223,10 +224,10 @@ Item {
readonly property var designs: {
var r = service ? service.designsRevision : 0
var words = searchText.trim().toLowerCase().split(/\s+/).filter(function(w) { return w.length > 0 })
if (words.length > 0) return Designs.all().filter(function(d) { return root.matchesSearch(d, words) })
if (mainTab === "animation") return Designs.animations()
if (words.length > 0) return Designs.all(root.userDesigns).filter(function(d) { return root.matchesSearch(d, words) })
if (mainTab === "animation") return Designs.animations(root.userDesigns)
if (mainTab === "favorites") return favoriteDesigns()
return Designs.stylings()
return Designs.stylings(root.userDesigns)
}
readonly property string pluginId: manifest && manifest.id ? String(manifest.id) : "io.github.sirjul1337.lock-explorer"
readonly property string activeDesignId: service ? service.designId
Expand Down Expand Up @@ -371,7 +372,7 @@ Item {
// `omarchy-shell lock setBoot`. Only designs with a Plymouth twin under
// plymouth/ can style it; "follow" tracks the lock design when it has one.
readonly property string followHint: {
var d = Designs.byId(activeDesignId)
var d = Designs.byId(activeDesignId, root.userDesigns)
var name = d ? d.name : root.tr("your lock screen")
if (d && d.boot === true) return root.tr("Boot matches %1 with its animated twin").arg(name)
return root.tr("Boot matches %1 as a still — same styling for both").arg(name)
Expand Down Expand Up @@ -401,12 +402,12 @@ Item {
if (bootApplied.length === 0) return root.tr("Stock Omarchy")
if (bootApplied === "theme") return root.tr("Theme colors")
if (bootApplied.indexOf("snapshot:") === 0) {
var sd = Designs.byId(bootApplied.substring(9))
var sd = Designs.byId(bootApplied.substring(9), root.userDesigns)
return root.tr("%1 (snapshot)").arg(sd ? sd.name : bootApplied.substring(9))
}
if (bootApplied.indexOf("custom:") === 0) return bootApplied.substring(7)
if (bootApplied.indexOf("video:") === 0) return bootApplied.substring(6).replace(/\.[^.]+$/, "")
var d = Designs.byId(bootApplied)
var d = Designs.byId(bootApplied, root.userDesigns)
return d ? d.name : bootApplied
}
readonly property var bootVideos: service && service.bootVideos !== undefined ? service.bootVideos : []
Expand All @@ -433,7 +434,7 @@ Item {
}
readonly property string bootFollowTarget: {
if (bootSetting !== "follow") return ""
var d = Designs.byId(activeDesignId)
var d = Designs.byId(activeDesignId, root.userDesigns)
return d && d.boot === true ? d.id : ""
}
readonly property int bootPreviewsVersion: service && service.bootPreviewsVersion !== undefined ? service.bootPreviewsVersion : 0
Expand Down Expand Up @@ -697,7 +698,7 @@ Item {
// setting on "follow".
function bootUseStyling(id, persist) {
if (root.bootApplying) return
var d = Designs.byId(id)
var d = Designs.byId(id, root.userDesigns)
if (d && d.boot === true) root.setBoot(id)
else root.snapshotAndApply(id, persist === undefined ? true : persist)
}
Expand All @@ -720,10 +721,10 @@ Item {
if (bootSetting === "stock") return "Untouched"
if (bootSetting === "theme") return "Theme colors"
if (bootSetting === "follow") {
var d = Designs.byId(activeDesignId)
var d = Designs.byId(activeDesignId, root.userDesigns)
return d && d.boot === true ? "Match lock (" + d.name + ")" : "Match lock (no twin)"
}
var picked = Designs.byId(bootSetting)
var picked = Designs.byId(bootSetting, root.userDesigns)
return picked ? picked.name : bootSetting
}
readonly property bool bootResync: service && service.bootResync !== undefined ? service.bootResync : true
Expand Down Expand Up @@ -810,7 +811,7 @@ Item {
if (bootSetting.indexOf("snapshot:") === 0) return bootSetting
if (bootSetting.indexOf("custom:") === 0 || bootSetting.indexOf("video:") === 0) return bootSetting
if (bootSetting === "follow") {
var d = Designs.byId(activeDesignId)
var d = Designs.byId(activeDesignId, root.userDesigns)
return d && d.boot === true ? d.id : "snapshot:" + activeDesignId
}
return bootSetting
Expand All @@ -821,12 +822,12 @@ Item {
if (w === "stock") return root.tr("Untouched")
if (w === "theme") return root.tr("Theme colors")
if (w.indexOf("snapshot:") === 0) {
var sd = Designs.byId(w.substring(9))
var sd = Designs.byId(w.substring(9), root.userDesigns)
return root.tr("%1 (snapshot)").arg(sd ? sd.name : w.substring(9))
}
if (w.indexOf("custom:") === 0) return w.substring(7)
if (w.indexOf("video:") === 0) return w.substring(6).replace(/\.[^.]+$/, "")
var d = Designs.byId(w)
var d = Designs.byId(w, root.userDesigns)
return d ? d.name : w
}

Expand Down Expand Up @@ -873,7 +874,7 @@ Item {
root.mainTab = root.requestedTab.length > 0 ? root.requestedTab : "styling"
root.requestedTab = ""
root.category = "all"
var idx = Designs.indexOf(root.activeDesignId)
var idx = Designs.indexOf(root.activeDesignId, root.userDesigns)
root.selectedIndex = idx >= 0 ? idx : 0
if (root.service) {
if (typeof root.service.rescanUserDesigns === "function") root.service.rescanUserDesigns()
Expand Down Expand Up @@ -936,7 +937,7 @@ Item {
if (id === root.category) return
var current = root.selectedDesign ? root.selectedDesign.id : ""
root.category = id
var list = Designs.inCategory(id)
var list = Designs.inCategory(id, root.userDesigns)
var keep = -1
for (var i = 0; i < list.length; i++) if (list[i].id === current) keep = i
root.selectedIndex = keep >= 0 ? keep : 0
Expand Down Expand Up @@ -1195,15 +1196,15 @@ Item {
root.setCategory("custom")
Qt.callLater(function() {
root.selectById(id)
var d = Designs.byId(id)
var d = Designs.byId(id, root.userDesigns)
if (d) root.openEditor(d)
})
}
function onDesignerDesignCreated(id, path) {
if (!root.opened) return
Qt.callLater(function() {
root.selectById(id)
var d = Designs.byId(id)
var d = Designs.byId(id, root.userDesigns)
if (d) root.openDesigner(d)
})
}
Expand Down Expand Up @@ -1233,7 +1234,7 @@ Item {
}

function useDesign(id, dismissAfter) {
if (!Designs.byId(String(id)) || selectDesignProc.running) return
if (!Designs.byId(String(id), root.userDesigns) || selectDesignProc.running) return
root.selectionError = ""
if (root.service && typeof root.service.setDesign === "function") {
if (root.service.setDesign(id)) {
Expand Down Expand Up @@ -1296,6 +1297,7 @@ Item {
anchors.fill: parent
designId: root.activeDesignId
revision: root.service ? root.service.designsRevision : 0
userDesigns: root.userDesigns
twelveHour: root.twelveHour
wallpaperBlur: root.wallpaperBlurValue
wallpaperDim: root.wallpaperDimShift
Expand Down Expand Up @@ -1519,9 +1521,9 @@ Item {
: root.tr("%1 designs match “%2”").arg(root.designs.length).arg(root.searchText.trim()))
+ " · " + root.tr("Esc clears")
if (root.mainTab === "favorites") return root.tr("%1 starred with F").arg(root.designs.length)
if (root.mainTab === "animation") return root.tr("%1 animated lock screens").arg(Designs.animations().length)
if (root.mainTab === "animation") return root.tr("%1 animated lock screens").arg(Designs.animations(root.userDesigns).length)
if (root.mainTab === "editor") return root.bootEditing.length > 0 ? root.tr("Editing %1").arg(root.bootEditing) : root.tr("Make a matching lock screen and boot screen")
return (root.mainTab === "styling" ? root.tr("%1 lock screen stylings").arg(Designs.stylings().length) + " · " : "") + root.currentThemeName + " · " + root.tr("Follows your theme")
return (root.mainTab === "styling" ? root.tr("%1 lock screen stylings").arg(Designs.stylings(root.userDesigns).length) + " · " : "") + root.currentThemeName + " · " + root.tr("Follows your theme")
}
textFormat: Text.PlainText
color: root.wallpaperBroken ? root.danger : root.muted
Expand Down Expand Up @@ -1682,7 +1684,7 @@ Item {
Text {
id: activeLabel
anchors.centerIn: parent
text: root.selectionError || root.tr("Active: %1").arg(Designs.byId(root.activeDesignId) ? Designs.byId(root.activeDesignId).name : root.activeDesignId)
text: root.selectionError || root.tr("Active: %1").arg(Designs.byId(root.activeDesignId, root.userDesigns) ? Designs.byId(root.activeDesignId, root.userDesigns).name : root.activeDesignId)
textFormat: Text.PlainText
color: root.foreground
font.family: root.fontFamily
Expand Down Expand Up @@ -2807,7 +2809,7 @@ Item {
}

Text {
text: root.tr("%1 as a still").arg(Designs.byId(root.activeDesignId) ? Designs.byId(root.activeDesignId).name : root.tr("current"))
text: root.tr("%1 as a still").arg(Designs.byId(root.activeDesignId, root.userDesigns) ? Designs.byId(root.activeDesignId, root.userDesigns).name : root.tr("current"))
textFormat: Text.PlainText
color: root.muted
font.family: root.fontFamily
Expand Down Expand Up @@ -3208,8 +3210,8 @@ Item {
model: {
var r = root.service ? root.service.designsRevision : 0
return [
{ id: "styling", name: "Styling", count: Designs.stylings().length },
{ id: "animation", name: "Animation", count: Designs.animations().length },
{ id: "styling", name: "Styling", count: Designs.stylings(root.userDesigns).length },
{ id: "animation", name: "Animation", count: Designs.animations(root.userDesigns).length },
{ id: "favorites", name: "Favorites", count: root.favoriteDesigns().length },
{ id: "boot", name: "Boot screen", count: 0 },
{ id: "settings", name: "Settings", count: 0 }
Expand Down Expand Up @@ -3426,6 +3428,7 @@ Item {
anchors.fill: parent
designId: root.selectedDesign ? root.selectedDesign.id : root.activeDesignId
revision: root.service ? root.service.designsRevision : 0
userDesigns: root.userDesigns
twelveHour: root.twelveHour
wallpaperBlur: root.wallpaperBlurValue
wallpaperDim: root.wallpaperDimShift
Expand Down Expand Up @@ -3676,6 +3679,7 @@ Item {
stillTextureSize: Qt.size(root.thumbWidth, root.thumbHeight)
designId: cell.modelData.id
revision: root.service ? root.service.designsRevision : 0
userDesigns: root.userDesigns
twelveHour: root.twelveHour
wallpaperBlur: root.wallpaperBlurValue
wallpaperDim: root.wallpaperDimShift
Expand Down Expand Up @@ -4105,6 +4109,7 @@ Item {
anchors.fill: parent
designId: root.selectedDesign ? root.selectedDesign.id : Designs.DEFAULT_ID
revision: root.service ? root.service.designsRevision : 0
userDesigns: root.userDesigns
twelveHour: root.twelveHour
wallpaperBlur: root.wallpaperBlurValue
wallpaperDim: root.wallpaperDimShift
Expand Down
4 changes: 3 additions & 1 deletion LockHost.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Item {

property string designId: Designs.DEFAULT_ID
property int revision: 0
// Service.userDesigns, the scanned ~/.config/omarchy/lock-designs.
property var userDesigns: []
property bool fadeIn: false

property string backgroundPath: ""
Expand Down Expand Up @@ -86,7 +88,7 @@ Item {

readonly property var design: {
var r = revision
return Designs.resolve(designId)
return Designs.resolve(designId, userDesigns)
}
readonly property bool isUserDesign: design && design.path ? true : false
readonly property string userLocalPath: isUserDesign ? decodeURIComponent(String(design.path).replace(/^file:\/\//, "")) : ""
Expand Down
Loading
Loading