Repository navigation
Expand file tree
/
Copy pathMain.qml
More file actions
1517 lines (1387 loc) · 67.4 KB
/
Copy pathMain.qml
File metadata and controls
1517 lines (1387 loc) · 67.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Pixie SDDM
* A minimal SDDM theme inspired by Pixel UI and Material Design 3.
* Author: xCaptaiN09
* GitHub: https://github.com/xCaptaiN09/pixie-sddm
*/
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Effects
import QtQuick.Shapes
import QtCore
import "components"
Rectangle {
id: container
width: 1920
height: 1080
color: config.backgroundColor
focus: !loginState.visible
// The icons are Nerd Font glyphs in the private use area, which Qt's font
// fallback does not reach, so they name the font that has them. Without
// it they draw as boxes once no regular text font carries them.
readonly property string iconFontFamily: config.iconFontFamily || "Symbols Nerd Font Mono"
// User & Session Logic (Root Level)
property int userIndex: 0
property int sessionIndex: 0
property bool isLoggingIn: false
// Keyboard layout picker. Hyprland is the compositor drawing this greeter,
// so the layout picked here has to change that Hyprland's real input
// config, not a label. QML cannot spawn hyprctl in the greeter sandbox, so
// pixie-sddm-keyboard-bridge.sh, started from that Hyprland's own config,
// does it: it publishes the layout in effect to a state file polled below
// and applies whatever the kbRequest Settings object writes. Reading a
// local file through XMLHttpRequest needs QML_XHR_ALLOW_FILE_READ=1 in
// the greeter's environment, which the SDDM config sets.
readonly property string kbStateDir: "/run/mainstream-greeter"
// Every layout XKB knows about, parsed from base.lst: code and variant to
// a friendly name. The picker offers all of them rather than the configured
// ones, because a machine set up with one layout is exactly where a guest
// needs another to type a password.
property var kbCatalog: []
property var kbActive: ({ code: "us", variant: "" })
// base.lst carries a few hundred entries, unusable as a flat list, so the
// picker filters on name or code as you type.
readonly property var kbFilteredCatalog: {
var f = layoutSearch.text.trim().toLowerCase();
if (!f) return kbCatalog;
return kbCatalog.filter(function(c) {
return c.name.toLowerCase().indexOf(f) !== -1
|| c.code.toLowerCase().indexOf(f) !== -1;
});
}
function kbLayoutId(entry) {
return entry.code + ":" + (entry.variant || "");
}
function kbDisplayName(entry) {
if (!entry) return "";
var id = kbLayoutId(entry);
var known = kbCatalog.find(function(c) { return kbLayoutId(c) === id; });
if (known) return known.name;
return entry.code.toUpperCase() + (entry.variant ? " " + entry.variant : "");
}
// The same three sections the Settings app's picker reads: "! layout",
// "! variant" and "! option", of which the last is not a layout.
function parseXkbCatalog(text) {
var catalog = [];
var section = "";
var lines = text.split("\n");
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
if (/^!\s*layout/.test(line)) { section = "layout"; continue; }
if (/^!\s*variant/.test(line)) { section = "variant"; continue; }
if (/^!/.test(line)) { section = ""; continue; }
if (section === "layout") {
var m = line.match(/^\s*(\S+)\s+(.+?)\s*$/);
if (m && m[1] !== "custom") catalog.push({ code: m[1], variant: "", name: m[2] });
} else if (section === "variant") {
var mv = line.match(/^\s*(\S+)\s+(\S+):\s*(.+?)\s*$/);
if (mv) catalog.push({ code: mv[2], variant: mv[1], name: mv[3] });
}
}
return catalog;
}
function loadKbCatalog() {
readLocalFile("file:///usr/share/X11/xkb/rules/base.lst", function(text) {
container.kbCatalog = parseXkbCatalog(text);
});
}
// Polls the snapshot the bridge publishes. Re-read on a timer rather than
// once, so a layout changed by anything other than this picker shows too.
function loadKbState() {
readLocalFile("file://" + container.kbStateDir + "/state", function(text) {
if (kbHoldTimer.running) return;
var layoutM = text.match(/^[ \t]*activeLayout[ \t]*=[ \t]*(.*?)[ \t\r]*$/m);
if (!layoutM || !layoutM[1]) return;
var variantM = text.match(/^[ \t]*activeVariant[ \t]*=[ \t]*(.*?)[ \t\r]*$/m);
var entry = { code: layoutM[1].trim(), variant: variantM ? variantM[1].trim() : "" };
if (container.kbLayoutId(entry) !== container.kbLayoutId(container.kbActive))
container.kbActive = entry;
});
}
// Shows the pick at once and hands it to the bridge, which rewrites
// input:kb_layout, so any layout XKB knows can be chosen whether or not
// the greeter booted with it.
function selectKbLayout(entry) {
if (!entry || !entry.code) return;
kbActive = { code: entry.code, variant: entry.variant || "" };
kbHoldTimer.restart();
// Variant first, so the bridge, which acts on the layout key, never
// reads a new layout against a stale variant.
kbRequest.requestedVariant = entry.variant || "";
kbRequest.requestedLayout = entry.code;
layoutPopup.close();
}
// QtCore's Settings writes plain key=value text through QSettings, the one
// documented way plain QML can write a file at all.
Settings {
id: kbRequest
location: "file:///run/mainstream-greeter/request"
property string requestedVariant: ""
property string requestedLayout: ""
}
Timer {
id: kbStateTimer
interval: 1200
repeat: true
running: true
triggeredOnStart: true
onTriggered: container.loadKbState()
}
// Running for a moment after a pick, so the poll does not flip the pill
// back to the old layout in the half second before the bridge applies it.
Timer {
id: kbHoldTimer
interval: 2500
}
// Layout scale. Every hardcoded pixel value below was sized for a 4K
// (2160 px tall) screen; we scale them down proportionally for smaller
// displays. Capped at 1.0 so 5K/6K screens still show the 4K layout
// without unintentionally enlarging UI further. height / 2160 is used
// (not Math.min(width/3840, height/2160)) because the layout is
// vertically dominated -- ultrawide screens at 2160 px tall should keep
// the 4K presentation, not shrink the form.
readonly property real uiScale: Math.min(1.0, height / 2160)
// Synced from /var/lib/pixie-sddm/state.conf (written by quickshell BarConfig).
// Empty string when the file is absent or doesn't carry the key — the date
// text falls back to month-first in that case.
property string syncedDateFormat: ""
// The one way plain QML can read a local file: XMLHttpRequest on file://,
// which needs QML_XHR_ALLOW_FILE_READ=1 in the greeter's environment. A
// missing or refused file answers with status 0 and no text rather than
// an error, so an empty answer counts as one.
function readLocalFile(url, onText) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState !== XMLHttpRequest.DONE) return;
var text = xhr.responseText || "";
if (xhr.status === 200 || text !== "") onText(text);
};
try {
xhr.open("GET", url);
xhr.send();
} catch (e) {
}
}
// Frames a second the login screen redraws a video wallpaper at, 0 for the
// file's own rate. Shares the state file the date format arrives in.
property int syncedVideoFrameRate: 0
function loadSyncedState() {
readLocalFile("file:///var/lib/pixie-sddm/state.conf", function(text) {
var m = text.match(/^[ \t]*dateFormat[ \t]*=[ \t]*(.*?)[ \t\r]*$/m);
if (m && m[1]) container.syncedDateFormat = m[1];
var f = text.match(/^[ \t]*videoFrameRate[ \t]*=[ \t]*([0-9]+)[ \t\r]*$/m);
if (f) container.syncedVideoFrameRate = parseInt(f[1], 10);
});
}
Component.onCompleted: {
loadSyncedState();
loadKbCatalog();
if (typeof userModel !== "undefined" && userModel.lastIndex >= 0) userIndex = userModel.lastIndex;
if (typeof sessionModel !== "undefined" && sessionModel.lastIndex >= 0) sessionIndex = sessionModel.lastIndex;
// onUserIndexChanged won't fire if userIndex stayed at 0 (single-user systems),
// so force-apply the initial per-user background via Qt.callLater to ensure
// bgCurrent is fully constructed before we touch it.
Qt.callLater(function() {
var newBg = getUserBackground(userIndex);
if (bgCurrent.source.toString() !== newBg.toString())
bgCurrent.source = newBg;
});
}
function cleanName(name) {
if (!name) return "";
var s = name.toString();
if (s.endsWith("/")) s = s.substring(0, s.length - 1);
if (s.indexOf("/") !== -1) s = s.substring(s.lastIndexOf("/") + 1);
if (s.indexOf(".desktop") !== -1) s = s.substring(0, s.indexOf(".desktop"));
s = s.replace(/[-_]/g, ' ');
return s.charAt(0).toUpperCase() + s.slice(1);
}
// Returns the background image path for a given user index.
// Looks for assets/backgrounds/<username>.png (or .jpg/.webp) then falls back to config.background.
function getUserBackground(index) {
if (typeof userModel === "undefined" || userModel.count === 0)
return config.background;
var idx = (index >= 0 && index < userModel.count) ? index : 0;
// Use NameRole (Qt.UserRole+1) — guaranteed to be the system login name,
// unlike Qt.EditRole which may return the display/real name on some SDDM builds.
var nameRole = userModel.data(userModel.index(idx, 0), Qt.UserRole + 1);
var username = nameRole ? nameRole.toString().trim() : "";
if (username)
return Qt.resolvedUrl("assets/backgrounds/" + username + ".png");
return config.background;
}
// The moving version of the same wallpaper, written beside the still by the
// desktop's wallpaper switcher. Missing is the normal case: the still shows.
function getUserVideo(index) {
var bg = getUserBackground(index).toString();
if (!bg.match(/\.(png|jpg|jpeg|webp)$/i))
return "";
return bg.replace(/\.[^.]+$/, ".mp4");
}
onUserIndexChanged: {
var newBg = getUserBackground(userIndex);
var currentSrc = bgCurrent.source.toString();
var newSrc = newBg.toString();
if (currentSrc === newSrc) return;
bgCrossfade.stop();
bgNext.opacity = 0;
bgNext.source = newBg;
if (videoBackground.item)
videoBackground.item.videoSource = container.getUserVideo(container.userIndex);
}
function doLogin() {
if (!loginState.visible || isLoggingIn) return;
var user = "";
if (typeof userModel !== "undefined" && userModel.count > 0) {
var idx = container.userIndex;
if (idx < 0 || idx >= userModel.count) idx = 0;
var edit = userModel.data(userModel.index(idx, 0), Qt.EditRole);
var nameRole = userModel.data(userModel.index(idx, 0), Qt.UserRole + 1);
var display = userModel.data(userModel.index(idx, 0), Qt.DisplayRole);
user = edit ? edit.toString() : (nameRole ? nameRole.toString() : (display ? display.toString() : ""));
}
if (!user || user === "" || user === "User") {
user = sddm.lastUser;
}
if (!user && typeof userModel !== "undefined" && userModel.count > 0) {
var firstEdit = userModel.data(userModel.index(0, 0), Qt.EditRole);
user = firstEdit ? firstEdit.toString() : "";
}
if (!user) return;
container.isLoggingIn = true;
var pass = passwordField.text;
var sess = container.sessionIndex;
if (typeof sessionModel !== "undefined") {
if (sess < 0 || sess >= sessionModel.count) sess = 0;
} else {
sess = 0;
}
console.log("Pixie SDDM: Attempting login for user [" + user + "] session index [" + sess + "]");
sddm.login(user.trim(), pass, sess);
loginTimeout.start();
}
Timer {
id: loginTimeout
interval: 5000
onTriggered: container.isLoggingIn = false
}
Connections {
target: sddm
function onLoginFailed() {
container.isLoggingIn = false
loginTimeout.stop()
loginState.isError = true
shakeAnimation.start()
passwordField.text = ""
passwordField.forceActiveFocus()
}
function onLoginSucceeded() {
loginTimeout.stop()
}
}
// Dynamic Color Extraction
property color extractedAccent: "#A9C78F"
Timer {
id: colorDelay
interval: 1000 // Give it a full second
repeat: true // Keep trying until we succeed
running: bgCurrent.status === Image.Ready && !colorExtractor.processed
onTriggered: colorExtractor.requestPaint()
}
Canvas {
id: colorExtractor
width: 60; height: 60
x: -100; y: -100 // Off-screen but "visible" for reliable rendering
z: -1
renderTarget: Canvas.Image
property bool processed: false
onPaint: {
var ctx = getContext("2d");
var res = 60;
ctx.clearRect(0, 0, res, res);
ctx.drawImage(bgCurrent, 0, 0, res, res);
var imgData = ctx.getImageData(0, 0, res, res).data;
if (!imgData || imgData.length === 0) return;
// 36 Buckets (10 degrees each) for high resolution hue detection
var histogram = new Array(36).fill(0);
var sampleColors = new Array(36).fill(null);
var vibrantFound = false;
for (var i = 0; i < imgData.length; i += 4) {
var r = imgData[i] / 255;
var g = imgData[i+1] / 255;
var b = imgData[i+2] / 255;
var pCol = Qt.rgba(r, g, b, 1.0);
// Filter: Must be colorful and not too dark
if (pCol.hsvSaturation > 0.3 && pCol.hsvValue > 0.25) {
var h = pCol.hsvHue * 360;
if (h < 0) continue;
var bIdx = Math.floor(h / 10) % 36;
// Weight: Focus on saturation to find the "intended" accent
var weight = pCol.hsvSaturation * pCol.hsvValue;
histogram[bIdx] += weight;
if (!sampleColors[bIdx] || weight > (sampleColors[bIdx].hsvSaturation * sampleColors[bIdx].hsvValue)) {
sampleColors[bIdx] = pCol;
}
vibrantFound = true;
}
}
if (!vibrantFound) return; // Keep trying
// Merge Red wrap (350-360 and 0-10)
histogram[0] += histogram[35];
// Find the most frequent vibrant hue (The Mode)
var maxCount = -1;
var winnerIdx = -1;
for (var j = 0; j < 35; j++) {
if (histogram[j] > maxCount) {
maxCount = histogram[j];
winnerIdx = j;
}
}
if (winnerIdx !== -1 && sampleColors[winnerIdx]) {
var finalColor = sampleColors[winnerIdx];
var h = finalColor.hsvHue;
// Slightly decreased saturation for a more professional look
var s = Math.max(0.35, Math.min(0.55, finalColor.hsvSaturation * 0.9));
container.extractedAccent = Qt.hsva(h, s, 0.95, 1.0);
console.log("Pixie SDDM: SUCCESS! Extracted Hue: " + (h * 360).toFixed(0) + "°");
processed = true; // Stop the timer
}
}
}
// Safety valve: if the background never loads (fresh install, missing file, etc.)
// force-show the UI after 3 s so the user is never stuck on a blank screen.
Timer {
id: startupSafety
interval: 3000
running: true
repeat: false
onTriggered: {
if (!colorExtractor.processed) colorExtractor.processed = true;
}
}
Connections {
target: bgCurrent
function onStatusChanged() {
if (bgCurrent.status === Image.Ready) {
colorExtractor.processed = false;
colorDelay.start();
} else if (bgCurrent.status === Image.Error) {
// Per-user background missing — try .jpg / .webp before
// falling back to the theme default. Mirrors bgNext's chain
// so the initial load isn't restricted to .png.
var src = bgCurrent.source.toString();
var fallback = Qt.resolvedUrl(config.background).toString();
if (src !== fallback && src.match(/\.png$/i)) {
bgCurrent.source = src.replace(/\.png$/i, ".jpg");
} else if (src !== fallback && src.match(/\.jpg$/i)) {
bgCurrent.source = src.replace(/\.jpg$/i, ".webp");
} else if (src !== fallback) {
bgCurrent.source = fallback;
} else {
// Even the default is missing — skip extraction, show UI with default accent.
colorExtractor.processed = true;
}
}
}
}
FontLoader { id: fontRegular; source: "assets/fonts/FlexRounded-R.ttf" }
FontLoader { id: fontMedium; source: "assets/fonts/FlexRounded-M.ttf" }
FontLoader { id: fontBold; source: "assets/fonts/FlexRounded-B.ttf" }
// Crossfade background container — holds the current and next background images.
// When the user changes, bgNext loads the new image and fades in over bgCurrent,
// then bgCurrent adopts the new source and bgNext is reset to transparent.
Item {
id: backgroundContainer
anchors.fill: parent
Image {
id: bgCurrent
anchors.fill: parent
source: config.background
fillMode: Image.PreserveAspectCrop
asynchronous: true
}
Image {
id: bgNext
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
asynchronous: true
opacity: 0
onStatusChanged: {
if (status === Image.Ready && source !== "") {
bgCrossfade.restart();
} else if (status === Image.Error) {
// Try .jpg extension before falling back to the theme default
var src = source.toString();
var defaultBg = Qt.resolvedUrl(config.background).toString();
if (src !== defaultBg && src.match(/\.png$/i)) {
source = src.replace(/\.png$/i, ".jpg");
} else if (src !== defaultBg && src.match(/\.jpg$/i)) {
source = src.replace(/\.jpg$/i, ".webp");
} else {
source = config.background;
}
}
}
}
// Loaded by name rather than imported, so a missing QtMultimedia costs
// the moving wallpaper and nothing else.
Loader {
id: videoBackground
anchors.fill: parent
asynchronous: true
source: "VideoBackground.qml"
onLoaded: {
item.frameRate = Qt.binding(function() { return container.syncedVideoFrameRate; });
item.videoSource = container.getUserVideo(container.userIndex);
}
}
SequentialAnimation {
id: bgCrossfade
NumberAnimation {
target: bgNext
property: "opacity"
from: 0; to: 1
duration: 600
easing.type: Easing.InOutQuad
}
ScriptAction {
script: {
bgCurrent.source = bgNext.source;
bgNext.opacity = 0;
}
}
}
}
// High-Quality Standalone Blur (Qt6 Native)
MultiEffect {
id: backgroundBlur
anchors.fill: parent
source: backgroundContainer
blurEnabled: true
blur: loginState.visible ? 1.0 : 0.0
opacity: loginState.visible ? 1.0 : 0.0
autoPaddingEnabled: false
Behavior on opacity { NumberAnimation { duration: 400; easing.type: Easing.InOutQuad } }
Behavior on blur { NumberAnimation { duration: 400; easing.type: Easing.InOutQuad } }
}
Rectangle {
anchors.fill: parent
color: "black"
opacity: loginState.visible ? 0.6 : 0.4
Behavior on opacity { NumberAnimation { duration: 400 } }
}
PowerBar {
anchors {
top: parent.top
right: parent.right
topMargin: 60 * container.uiScale
rightMargin: 80 * container.uiScale
}
uiScale: container.uiScale
textColor: container.extractedAccent
iconFontFamily: container.iconFontFamily
z: 100
opacity: colorExtractor.processed ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
Shortcut {
sequence: "Escape"
enabled: loginState.visible
onActivated: {
loginState.visible = false;
loginState.isError = false;
passwordField.text = "";
container.focus = true;
}
}
Shortcut {
sequences: ["Return", "Enter"]
enabled: loginState.visible
onActivated: container.doLogin()
}
Text {
id: dateText
// Order follows the quickshell BarConfig date-format choice:
// day-first ("dd/MM"-style) → "Monday, 27 Apr"
// month-first (default) → "Monday, Apr 27"
text: {
var fmt = container.syncedDateFormat;
if (fmt) {
var ddIdx = fmt.indexOf("dd");
var mmIdx = fmt.indexOf("MM");
if (ddIdx >= 0 && mmIdx >= 0 && ddIdx < mmIdx)
return Qt.formatDateTime(new Date(), "dddd, d MMM");
}
return Qt.formatDateTime(new Date(), "dddd, MMM d");
}
color: container.extractedAccent
font.pixelSize: 44 * container.uiScale
font.family: config.fontFamily
anchors {
top: parent.top
left: parent.left
topMargin: 100 * container.uiScale
leftMargin: 120 * container.uiScale
}
opacity: colorExtractor.processed ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
Item {
id: lockState
anchors.fill: parent
visible: !loginState.visible
opacity: visible ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 400 } }
Clock {
id: mainClock
anchors.centerIn: parent
backgroundSource: bgCurrent.source
baseAccent: container.extractedAccent
fontFamily: config.fontFamily
uiScale: {
var percent = Number(config.clockSize);
if (!isFinite(percent) || percent <= 0) percent = 100;
return container.uiScale * Math.max(50, Math.min(200, percent)) / 100;
}
clockFormat: {
var cfg = (config.clockFormat || "").toString().trim();
// Explicit override in theme.conf wins.
if (cfg && cfg !== "auto") return cfg;
// Auto: mirror the system locale's short time format.
// Qt.locale().timeFormat() respects LC_TIME set via localectl,
// which is the same OS-level setting quickshell reads.
return Qt.locale().timeFormat(Locale.ShortFormat);
}
opacity: colorExtractor.processed ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 300 } }
}
Text {
text: "Press any key to unlock"
color: config.textColor
font.pixelSize: 32 * container.uiScale
font.family: config.fontFamily
font.weight: Font.Medium
anchors {
bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
bottomMargin: 200 * container.uiScale
}
opacity: 0.5
}
MouseArea {
anchors.fill: parent
onClicked: {
loginState.visible = true;
passwordField.forceActiveFocus();
}
}
}
Item {
id: loginState
anchors.fill: parent
visible: false
opacity: visible ? 1 : 0
z: 10
Behavior on opacity { NumberAnimation { duration: 400 } }
onVisibleChanged: {
if (visible) passwordField.forceActiveFocus();
}
property bool isError: false
SequentialAnimation {
id: shakeAnimation
loops: 2
PropertyAnimation { target: loginCard; property: "x"; from: (container.width - loginCard.width)/2; to: (container.width - loginCard.width)/2 - 10 * container.uiScale; duration: 50; easing.type: Easing.InOutQuad }
PropertyAnimation { target: loginCard; property: "x"; from: (container.width - loginCard.width)/2 - 10 * container.uiScale; to: (container.width - loginCard.width)/2 + 10 * container.uiScale; duration: 50; easing.type: Easing.InOutQuad }
PropertyAnimation { target: loginCard; property: "x"; from: (container.width - loginCard.width)/2 + 10 * container.uiScale; to: (container.width - loginCard.width)/2; duration: 50; easing.type: Easing.InOutQuad }
onStopped: isError = false
}
// Centered login UI -- no card background; elements float over the blurred wallpaper.
// Kept as `loginCard` so the existing shake animation references still target it.
// All children sized 2x the brand spec for a larger on-screen presence.
Item {
id: loginCard
width: 800 * container.uiScale
height: contentColumn.implicitHeight
x: (parent.width - width) / 2
y: (parent.height - height) / 2
Column {
id: contentColumn
width: parent.width
anchors.verticalCenter: parent.verticalCenter
spacing: 48 * container.uiScale
Item {
id: avatarItem
width: 272 * container.uiScale
height: 272 * container.uiScale
anchors.horizontalCenter: parent.horizontalCenter
// True only when AccountsService gives us a real per-user icon.
// Many distros (and SDDM itself) return a default system silhouette
// path under /usr/share/... for users that haven't set anything --
// we filter those out by location so they fall through to the letter.
property bool hasCustomAvatar: {
if (typeof userModel === "undefined" || userModel.count === 0) return false;
var idx = container.userIndex;
if (idx < 0 || idx >= userModel.count) return false;
var icon = userModel.data(userModel.index(idx, 0), Qt.UserRole + 4);
if (!icon) return false;
var path = icon.toString().trim().toLowerCase();
if (path.length === 0) return false;
// Strip file:// prefix if Qt returned a URL form
if (path.indexOf("file://") === 0) path = path.substring(7);
// Real custom avatars live in well-known per-user locations.
if (path.indexOf("/var/lib/accountsservice/icons/") !== -1) return true;
if (path.indexOf("/home/") !== -1) return true;
// Anything else (e.g. /usr/share/sddm/faces, /usr/share/pixmaps,
// /usr/share/icons) is a system default -- treat as no avatar.
return false;
}
// Glass-style avatar circle with letter initial. Shown unless the
// user has a real custom photo that loaded successfully.
Rectangle {
id: avatarFallback
anchors.fill: parent
radius: width / 2
visible: !avatarItem.hasCustomAvatar || avatar.status !== Image.Ready
border.width: 1
border.color: Qt.rgba(1, 1, 1, 0.08)
gradient: Gradient {
GradientStop { position: 0.0; color: loginState.isError ? Qt.rgba(1, 0.4, 0.4, 0.20) : Qt.rgba(1, 1, 1, 0.10) }
GradientStop { position: 1.0; color: loginState.isError ? Qt.rgba(1, 0.4, 0.4, 0.06) : Qt.rgba(1, 1, 1, 0.03) }
}
Text {
anchors.centerIn: parent
text: {
var n = "";
if (typeof userModel !== "undefined" && userModel.count > 0) {
var d = userModel.data(userModel.index(container.userIndex, 0), Qt.DisplayRole);
var nr = userModel.data(userModel.index(container.userIndex, 0), Qt.UserRole + 1);
n = d ? d.toString() : (nr ? nr.toString() : "U");
} else {
n = sddm.lastUser ? sddm.lastUser : "U";
}
return n.charAt(0).toLowerCase();
}
color: "white"
font.pixelSize: 112 * container.uiScale
font.family: fontMedium.name
font.weight: Font.Medium
}
}
// Photo avatar (Canvas + Image). Only used when AccountsService
// provides a real icon path. If empty -> falls through to the
// letter-initial fallback above (no theme-default silhouette).
Canvas {
id: avatarCanvas
anchors.fill: parent
visible: avatarItem.hasCustomAvatar && avatar.status === Image.Ready
onPaint: {
var ctx = getContext("2d");
ctx.reset();
ctx.beginPath();
ctx.arc(width / 2, height / 2, width / 2, 0, 2 * Math.PI);
ctx.closePath();
ctx.clip();
// PreserveAspectCrop: scale image so its shorter axis fills the
// canvas, then centre it so the excess is cropped equally.
var iw = avatar.implicitWidth;
var ih = avatar.implicitHeight;
if (iw > 0 && ih > 0) {
var scale = Math.max(width / iw, height / ih);
var dw = iw * scale;
var dh = ih * scale;
ctx.drawImage(avatar, (width - dw) / 2, (height - dh) / 2, dw, dh);
} else {
ctx.drawImage(avatar, 0, 0, width, height);
}
}
Image {
id: avatar
anchors.fill: parent
smooth: true
visible: false
source: {
// Only load when AccountsService gives us a real path -- otherwise
// we'd display the theme's default silhouette, which we don't want.
if (typeof userModel === "undefined" || userModel.count === 0) return "";
var idx = container.userIndex;
if (idx < 0 || idx >= userModel.count) return "";
// IconRole = Qt.UserRole+4 in SDDM 0.18+ (Qt6 era).
// Qt.UserRole+3 is HomeDirRole and must not be used here.
// AccountsService icon paths have no file extension, so
// accept any non-empty string rather than requiring one.
var icon = userModel.data(userModel.index(idx, 0), Qt.UserRole + 4);
if (icon && icon.toString().trim().length > 0) {
return Qt.resolvedUrl(icon.toString().trim());
}
return "";
}
onStatusChanged: {
if (status === Image.Ready) avatarCanvas.requestPaint();
}
}
}
}
// Username -- centered, plain text, click to switch user (multi-user systems)
Item {
anchors.horizontalCenter: parent.horizontalCenter
width: userNameLabel.width + 80 * container.uiScale
height: userNameLabel.height + 32 * container.uiScale
Rectangle {
anchors.fill: parent
color: "white"
opacity: userClickArea.pressed ? 0.10 : 0
radius: 24 * container.uiScale
Behavior on opacity { NumberAnimation { duration: 100 } }
}
Text {
id: userNameLabel
anchors.centerIn: parent
text: {
if (typeof userModel !== "undefined" && userModel.count > 0) {
var idx = container.userIndex;
var modelIdx = userModel.index(idx, 0);
var display = userModel.data(modelIdx, Qt.DisplayRole);
var edit = userModel.data(modelIdx, Qt.EditRole);
var nr = userModel.data(modelIdx, Qt.UserRole + 1);
var realName = userModel.data(modelIdx, Qt.UserRole + 2);
var finalName = display ? display.toString() : (realName ? realName.toString() : (nr ? nr.toString() : (edit ? edit.toString() : "User")));
return cleanName(finalName) + (userModel.count > 1 ? " ▾" : "");
}
return cleanName(sddm.lastUser ? sddm.lastUser : "User");
}
color: "white"
font.pixelSize: 56 * container.uiScale
font.weight: Font.Medium
font.family: config.fontFamily
}
MouseArea {
id: userClickArea
anchors.fill: parent
onClicked: userPopup.open()
}
scale: userClickArea.pressed ? 0.97 : 1.0
Behavior on scale { NumberAnimation { duration: 100 } }
}
// Password field with embedded submit button
Item {
id: passwordContainer
width: 720 * container.uiScale
height: 112 * container.uiScale
anchors.horizontalCenter: parent.horizontalCenter
TextField {
id: passwordField
anchors.fill: parent
echoMode: TextInput.Password
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
leftPadding: 48 * container.uiScale
rightPadding: 120 * container.uiScale
font.pixelSize: 30 * container.uiScale
font.family: config.fontFamily
color: "transparent" // Hide the actual password characters
selectionColor: Qt.rgba(1, 1, 1, 0.2)
selectedTextColor: "transparent"
focus: loginState.visible
enabled: !container.isLoggingIn
selectByMouse: true
// Suppress default thin cursor — a custom thick one is drawn
// in the symbols Flickable below so it tracks the visible symbols.
cursorDelegate: Item { width: 0; height: 0 }
background: Rectangle {
radius: 56 * container.uiScale
border.width: 0
opacity: parent.enabled ? 1.0 : 0.5
gradient: Gradient {
GradientStop { position: 0.0; color: loginState.isError ? Qt.rgba(1, 0.4, 0.4, 0.06) : Qt.rgba(1, 1, 1, 0.03) }
GradientStop { position: 1.0; color: loginState.isError ? Qt.rgba(1, 0.4, 0.4, 0.20) : Qt.rgba(1, 1, 1, 0.10) }
}
}
Text {
text: "Password"
color: Qt.rgba(1, 1, 1, 0.35)
font.pixelSize: 30 * container.uiScale
font.family: config.fontFamily
visible: !parent.text
anchors.verticalCenter: parent.verticalCenter
x: parent.leftPadding
}
onAccepted: container.doLogin()
}
// Animated Password Symbols (Moved outside TextField to avoid clipping)
Flickable {
id: symbolsFlickable
anchors.left: passwordField.left
anchors.leftMargin: passwordField.leftPadding
anchors.right: passwordField.right
anchors.rightMargin: passwordField.rightPadding
anchors.verticalCenter: passwordField.verticalCenter
height: 48 * container.uiScale
clip: true
interactive: false // Controlled by password length
contentWidth: cursorIndicator.x + cursorIndicator.width
contentX: Math.max(0, contentWidth - width)
Behavior on contentX {
NumberAnimation { duration: 200; easing.type: Easing.OutQuad }
}
// Thick custom cursor — sits at the end of the visible symbols.
// Matches the symbol color so it reads as part of the same row.
Rectangle {
id: cursorIndicator
width: 6 * container.uiScale
height: 42 * container.uiScale
radius: 3 * container.uiScale
color: config.primaryColor
y: (symbolsFlickable.height - height) / 2
x: passwordField.text.length > 0
? symbolsRow.x + symbolsRow.width + 10 * container.uiScale
: 0
visible: passwordField.activeFocus && !container.isLoggingIn
opacity: 0.85
Behavior on x {
NumberAnimation { duration: 200; easing.type: Easing.OutQuad }
}
SequentialAnimation on opacity {
loops: Animation.Infinite
running: cursorIndicator.visible
NumberAnimation { from: 0.85; to: 0.0; duration: 530; easing.type: Easing.InOutQuad }
NumberAnimation { from: 0.0; to: 0.85; duration: 530; easing.type: Easing.InOutQuad }
}
}
Row {
id: symbolsRow
spacing: 12 * container.uiScale
visible: passwordField.text.length > 0
Repeater {
model: passwordField.text.length
delegate: Item {
width: 42 * container.uiScale
height: 42 * container.uiScale
MaterialShape {
id: materialShape
anchors.centerIn: parent
implicitSize: 42 * container.uiScale
color: config.primaryColor
property list<var> charShapes: [
MaterialShape.Shape.Clover4Leaf,
MaterialShape.Shape.Arrow,
MaterialShape.Shape.Pill,
MaterialShape.Shape.SoftBurst,
MaterialShape.Shape.Diamond,
MaterialShape.Shape.ClamShell,
MaterialShape.Shape.Pentagon,
]
shape: charShapes[index % charShapes.length]
scale: 0
opacity: 0
Component.onCompleted: {
appearAnim.start()
}
ParallelAnimation {
id: appearAnim
NumberAnimation { target: materialShape; property: "scale"; from: 0.3; to: 1.0; duration: 250; easing.type: Easing.OutBack }
NumberAnimation { target: materialShape; property: "opacity"; from: 0; to: 0.7; duration: 150 }
}
}
}
}
}
}
// Submit button -- small circle inside the field's right edge.
// Brand spec: 32px diameter (~57% of field height); scaled 2x to 64px.
Rectangle {
id: submitButton