sddm-i3-theme

This commit is contained in:
krizej 2024-08-01 22:51:57 +02:00
parent a432aeafb9
commit 19f3c5eaee
17 changed files with 958 additions and 5 deletions

View file

@ -0,0 +1,16 @@
maya
----------------------------------------------------------------------
This theme follow the licencing policy of SDDM.
1) All QML files are available under terms of the MIT License.
2) The material design icons from https://design.google.com/icons/
have been used in the theme.
These icon are available under the Creative Common Attribution 4.0
International License (CC-BY 4.0).
3) Open Sans Condensed font downloaded from Font Squirrel is available
under the Apache License version 2.0.
(https://www.fontsquirrel.com/license/open-sans-condensed)
----------------------------------------------------------------------

View file

@ -0,0 +1,374 @@
//
// [maya] main.qml
//
// Main script for the SDDM theme
//
// (c) 2016 Sanjeev Premi (spremi@ymail.com)
//
// SPDX-License-Identifier: MIT
// (https://spdx.org/licenses/MIT.html)
//
import QtQuick 2.15
import QtQuick.Controls 2.0
import SddmComponents 2.0
import "components"
Rectangle {
id : gRoot
property color cTextNormal : "#ffffff"
property color cTextFailure : "#f43841"
property color cTextSuccess : "#00ff00"
property color cBackgroundRoot : "#000000"
property color cBackgroundNormal : "#333333"
property color cBackgroundActive : "#285577"
property color cBorderNormal : "#222222"
property color cBorderActive : "#4c7899"
property string fontFamily : "monospace"
property int fontSize : 16
property string defaultUser : ""
property int panelSize : 420
property int offset : 96
color: cBackgroundRoot
property int activeInput : initInputs()
property int currentSessionsIndex : sessionModel.lastIndex
property string currentSession: sessionModel.data(sessionModel.index(currentSessionsIndex, 0), Qt.UserRole + 4)
function xCenter(sz) {
return gRoot.width / 2 - sz / 2;
}
function yCenter(sz) {
return gRoot.height / 2 - sz / 2;
}
function initInputs() {
if(defaultUser != "") {
gPasswordInput.forceActiveFocus();
return 1;
} else {
gLoginInput.forceActiveFocus();
return 0;
}
}
function initInfoText() {
var text = "";
if(sddm.canPowerOff) {
text += "f1 shutdown"
}
if(sddm.canReboot) {
if(text != "") {
text += " "
}
text += "f2 reboot"
}
return text;
}
function sessionsCycleSelectPrev() {
if(timer.running) {
return;
}
if (currentSessionsIndex - 1 < 0) {
currentSessionsIndex = sessionModel.rowCount() - 1;
} else {
currentSessionsIndex--;
}
}
function sessionsCycleSelectNext() {
if(timer.running) {
return;
}
if (currentSessionsIndex >= sessionModel.rowCount() - 1) {
currentSessionsIndex = 0;
} else {
currentSessionsIndex++;
}
}
function focusNext() {
if(timer.running) {
return;
}
if(gRoot.activeInput == 0) {
gPasswordInput.forceActiveFocus();
gRoot.activeInput = 1;
} else if(gRoot.activeInput == -1) {
gLoginInput.forceActiveFocus();
gRoot.activeInput = 0;
}
}
function focusPrev() {
if(timer.running) {
return;
}
if(gRoot.activeInput == 1) {
gLoginInput.forceActiveFocus();
gRoot.activeInput = 0;
} else if(gRoot.activeInput == 0) {
gSessionBox.forceActiveFocus();
gRoot.activeInput = -1;
}
}
function setInputLock(lock) {
gLoginInput.readOnly = lock;
gPasswordInput.readOnly = lock;
gLoginInput.enabled = !lock;
gPasswordInput.enabled = !lock;
gSessionBox.enabled = !lock;
}
Timer {
id: timer
interval: 750
repeat: true
running: false
onTriggered: {
gInfoLabel.text += ".";
}
}
function tryLogin() {
gInfoLabel.color = cTextNormal;
gInfoLabel.text = ".";
timer.start();
setInputLock(true);
sddm.login(gLoginInput.text, gPasswordInput.text, currentSessionsIndex);
}
Connections {
target: sddm
function onLoginSucceeded() {
timer.stop();
gInfoLabel.color = cTextSuccess
gInfoLabel.text = "success"
}
function onLoginFailed() {
timer.stop();
gInfoLabel.color = cTextFailure
gInfoLabel.text = "auth failure"
setInputLock(false);
}
}
Shortcut {
sequence: "Down"
onActivated: focusNext();
}
Shortcut {
sequence: "Up"
onActivated: focusPrev();
}
Shortcut {
sequence: "F1"
onActivated: {
sddm.powerOff();
}
}
Shortcut {
sequence: "F2"
onActivated: {
sddm.reboot();
}
}
Text {
x: xCenter(panelSize)
y: yCenter(panelSize)
width: panelSize
height: 2 * fontSize
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
font.pixelSize: fontSize
font.family: fontFamily
color: cTextNormal
text: sddm.hostName;
}
Text {
x: 0
y: gRoot.height - 2 * fontSize
width: gRoot.width
height: 2 * fontSize
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
font.pixelSize: fontSize
font.family: fontFamily
color: cTextNormal
text: initInfoText();
}
Rectangle {
x: xCenter(panelSize)
y: yCenter(panelSize) + 3 * fontSize
Text {
width: panelSize
height: 2 * fontSize
horizontalAlignment: Qt.AlignHLeft
verticalAlignment: Qt.AlignVCenter
font.pixelSize: fontSize
font.family: fontFamily
color: cTextNormal
text: "session:"
}
SessionSelect {
id: gSessionBox
x: offset
width: panelSize - offset
height: fontSize * 2
text: currentSession
onPrevClicked: sessionsCycleSelectPrev();
onNextClicked: sessionsCycleSelectNext();
KeyNavigation.tab : gLoginInput
Keys.onPressed: function (event) {
if(event.key == Qt.Key_Return || event.key == Qt.Key_Enter) {
focusNext();
event.accepted = true;
}
}
}
}
Rectangle {
x: xCenter(panelSize)
y: yCenter(panelSize) + 2 * 3 * fontSize
Text {
width: panelSize
height: 2 * fontSize
horizontalAlignment: Qt.AlignHLeft
verticalAlignment: Qt.AlignVCenter
font.pixelSize: fontSize
font.family: fontFamily
color: cTextNormal
text: "login:"
}
TextBoxCustom {
id: gLoginInput
x: offset
width: panelSize - offset
height: 2 * fontSize
font.pixelSize: fontSize
font.family: fontFamily
cText: cTextNormal
// TODO set the remaining colors
text: defaultUser
KeyNavigation.tab : gPasswordInput
KeyNavigation.backtab : gSessionBox
Keys.onPressed: function (event) {
if(event.key == Qt.Key_Return || event.key == Qt.Key_Enter) {
focusNext();
event.accepted = true;
}
}
}
}
Rectangle {
x: xCenter(panelSize)
y: yCenter(panelSize) + 3 * 3 * fontSize
Text {
width: panelSize
height: 2 * fontSize
horizontalAlignment: Qt.AlignHLeft
verticalAlignment: Qt.AlignVCenter
font.pixelSize: fontSize
font.family: fontFamily
color: cTextNormal
text: "password:"
}
TextBoxCustom {
id: gPasswordInput
x: offset
width: panelSize - offset
height: 2 * fontSize
font.pixelSize: fontSize
font.family: fontFamily
cText: cTextNormal
// todo set the remaining colors here
echoMode: TextInput.Password
Keys.onPressed: function(event) {
if(event.key == Qt.Key_Return || event.key == Qt.Key_Enter) {
tryLogin();
event.accepted = true;
}
}
}
}
Text {
id: gInfoLabel
text: ""
x: xCenter(panelSize)
y: yCenter(panelSize) + 4 * 3 * fontSize
width: panelSize
height: 2 * fontSize
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
color: cTextNormal
}
}

View file

@ -0,0 +1,31 @@
1. INTRODUCTION
In Hindi, 'maya' refers to 'material wealth'.
This is a simple 'material' inspired SDDM theme.
2. BACKGROUND
While contributing new translations, I tried testing them on
my working Linux machine. But only few strings appeared to be
translated.
Took some time, to discover that SDDM theme on my desktop was
not using strings from SDDM. Few other themes I tried, weren't
using all the strings.
Necessity to test translations was the driving force behind
this theme. The 'material' inspiration helps in keeping focus
on original intent.
3. ACKNOWLEDGEMENTS
1. The basic theme and colors are material inspired.
2. Material Icons have been used from:
https://design.google.com/icons/
3. Open Sans Condensed font from Font Squirrel.
https://www.fontsquirrel.com/

View file

@ -0,0 +1,121 @@
import QtQuick 2.15
import QtQuick.Controls 2.0
FocusScope {
id: root
signal prevClicked()
signal nextClicked()
property string fontFamily: "monospace"
property int fontSize: 16
property string prevText: "<"
property string nextText: ">"
property string text: ""
property color textColor: "#ffffff"
property color cNormalBorder : "#222222"
property color cNormalBackground : "#333333"
property color cFocusBorder : "#4c7899"
property color cFocusBackground : "#285577"
Shortcut {
sequence: "Left"
onActivated: {
prevClicked()
}
}
Shortcut {
sequence: "Right"
onActivated: {
nextClicked()
}
}
Rectangle {
id: main
anchors.fill: root
color: cNormalBackground
border.color: cNormalBorder
border.width: 1
states: [
State {
name: "focus"
when: root.activeFocus
PropertyChanges {
target: main
color: cFocusBackground
border.color: cFocusBorder
border.width: 1
}
}
]
MouseArea {
anchors.fill: parent
onClicked: {
root.focus = true;
}
}
Text {
id: sessionName
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pixelSize: root.fontSize
font.family: root.fontFamily
color: textColor
text: root.text
anchors {
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
}
}
Text {
id: prevButton
text: root.prevText
color: textColor
font.pixelSize: root.fontSize
font.family: root.fontFamily
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
rightMargin: 10
leftMargin: 8
}
MouseArea {
anchors.fill: parent
onClicked: {
root.prevClicked();
root.focus = true;
}
}
}
Text {
id: nextButton
text: root.nextText
color: textColor
font.pixelSize: root.fontSize
font.family: "monospace"
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
leftMargin: 10
rightMargin: 8
}
MouseArea {
anchors.fill: parent
onClicked: {
root.nextClicked();
root.focus = true;
}
}
}
}
}

View file

@ -0,0 +1,206 @@
//
// [maya] components/SpButton.qml
//
// Implements custom action button with label
//
// (c) 2016 Sanjeev Premi (spremi@ymail.com)
//
// SPDX-License-Identifier: MIT
// (https://spdx.org/licenses/MIT.html)
//
import QtQuick 2.0
Item {
id : sp_button
property bool enabled : true
property alias icon : sp_button_icon.source
property alias label : sp_button_label.text
property alias font : sp_button_label.font
property color iconColor : "#aaaaaa"
property color labelColor : "#424242"
property color hoverIconColor : "#cccccc"
property color hoverLabelColor : "#808080"
property color pressIconColor : "#dcdcdc"
property color pressLabelColor : "#a0a0a0"
property color disableColor : "#888888"
signal pressed()
signal released()
signal clicked()
Row {
x : 4
y : 4
spacing : 8
Rectangle {
id : sp_button_bg
width : 40
height : 40
radius : 20
color : iconColor
Image {
id : sp_button_icon
width : 40
height : 40
source : "./blank.svg"
fillMode : Image.Pad
horizontalAlignment : Image.AlignHCenter
verticalAlignment : Image.AlignVCenter
}
}
Text {
id : sp_button_label
height : 40
text : ""
color : labelColor
font.pixelSize : 24
font.weight : Font.DemiBold
fontSizeMode : Text.VerticalFit
horizontalAlignment : Text.AlignRight
verticalAlignment : Text.AlignVCenter
}
}
//
// States and associated visual attributes
//
states: [
State {
name : "disabled"
when : (sp_button.enabled === false)
PropertyChanges {
target : sp_button_bg
color : disableColor
}
PropertyChanges {
target : sp_button_label
color : disableColor
}
},
State {
name : "hover"
PropertyChanges {
target : sp_button_label
color : hoverLabelColor
}
PropertyChanges {
target : sp_button_bg
color : hoverIconColor
}
},
State {
name : "pressed"
PropertyChanges {
target : sp_button_label
color : hoverLabelColor
}
PropertyChanges {
target : sp_button_bg
color : pressIconColor
}
}
]
//
// Behavior on state transitions
//
transitions: [
Transition {
from : ""
to : "hover"
ColorAnimation {
duration: 250
}
},
Transition {
from : ""
to : "pressed"
ColorAnimation {
duration: 25
}
},
Transition {
from : "disabled"
to : "enabled"
ColorAnimation {
duration: 50
}
},
Transition {
from : "enabled"
to : "disabled"
ColorAnimation {
duration: 50
}
}
]
//
// Area to react to mouse actions
//
MouseArea {
anchors.fill : sp_button
hoverEnabled : true
cursorShape : Qt.PointingHandCursor
acceptedButtons : Qt.LeftButton
onEntered : {
sp_button.state = "hover"
}
onExited : {
sp_button.state = ""
}
onPressed : {
sp_button.state = "pressed"
}
onClicked : {
sp_button.clicked()
}
onReleased : {
if (containsMouse) {
sp_button.state = "hover"
} else {
sp_button.state = ""
}
}
}
}

View file

@ -0,0 +1,49 @@
//
// [maya] components/SpClock.qml
//
// Implements custom clock component
//
// (c) 2016 Sanjeev Premi (spremi@ymail.com)
//
// SPDX-License-Identifier: MIT
// (https://spdx.org/licenses/MIT.html)
//
import QtQuick 2.0
Item {
id : sp_clock
property date value : new Date()
property color tColor : "white"
property alias tFont : sp_clock_text.font
implicitWidth : sp_clock_text.implicitWidth
implicitHeight : sp_clock_text.implicitHeight
Timer {
interval : 100
running : true
repeat : true;
onTriggered : sp_clock.value = new Date()
}
Text {
id : sp_clock_text
text : Qt.formatDateTime(sp_clock.value, "dddd, dd MMMM yyyy HH:mm AP")
color : sp_clock.tColor
font.pixelSize : 24
fontSizeMode : Text.VerticalFit
horizontalAlignment : Text.AlignHCenter
verticalAlignment : Text.AlignVCenter
}
}

View file

@ -0,0 +1,87 @@
/***************************************************************************
* Copyright (c) 2013 Abdurrahman AVCI <abdurrahmanavci@gmail.com>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*
***************************************************************************/
import QtQuick 2.0
FocusScope {
id: container
width: 80; height: 30
property color cNormalBorder : "#222222"
property color cNormalBackground : "#333333"
property color cFocusBorder : "#4c7899"
property color cFocusBackground : "#285577"
property alias font: txtMain.font
property alias cText: txtMain.color
property alias echoMode: txtMain.echoMode
property alias text: txtMain.text
property alias readOnly: txtMain.readOnly
Rectangle {
id: main
anchors.fill: parent
color: container.cNormalBackground
border.color: container.cNormalBorder
border.width: 1
states: [
State {
name: "focus"
when: container.activeFocus
PropertyChanges {
target: main
color: container.cFocusBackground
border.color: container.cFocusBorder
border.width: 1;
}
}
]
}
MouseArea {
id: mouseArea
anchors.fill: container
cursorShape: Qt.IBeamCursor
onClicked: container.focus = true;
}
TextInput {
id: txtMain
width: parent.width - 16
anchors.centerIn: parent
color: "black"
clip: true
focus: true
passwordCharacter: "*"
}
}

Binary file not shown.

View file

@ -0,0 +1,4 @@
<svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="M7 10l5 5 5-5z"/>
<path d="M0 0h24v24H0z" fill="none"/>
</svg>

After

Width:  |  Height:  |  Size: 178 B

View file

@ -0,0 +1,4 @@
<svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M13 3h-2v10h2V3zm4.83 2.17l-1.42 1.42C17.99 7.86 19 9.81 19 12c0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.19 1.01-4.14 2.58-5.42L6.17 5.17C4.23 6.82 3 9.26 3 12c0 4.97 4.03 9 9 9s9-4.03 9-9c0-2.74-1.23-5.18-3.17-6.83z"/>
</svg>

After

Width:  |  Height:  |  Size: 372 B

View file

@ -0,0 +1,4 @@
<svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/>
<path d="M0 0h24v24H0z" fill="none"/>
</svg>

After

Width:  |  Height:  |  Size: 366 B

View file

@ -0,0 +1,4 @@
<svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/>
</svg>

After

Width:  |  Height:  |  Size: 214 B

View file

@ -0,0 +1,13 @@
[SddmGreeterTheme]
Name=sddm-i3
Description=Simple i3 inspired theme
Author=krizej
Copyright=(c) 2024, krizej
License=MIT
Type=sddm-theme
Version=1
Website=https://github.com/krizej
MainScript=Main.qml
ConfigFile=theme.conf
Theme-Id=sddm-i3
Theme-API=2.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View file

@ -0,0 +1,24 @@
[General]
primaryShade=
primaryLight=
primaryDark=
primaryHue1=
primaryHue2=
primaryHue3=
accentShade=
accentLight=
accentHue1=
accentHue2=
accentHue3=
normalText=
successText=
failureText=
warningText=
rebootColor=
powerColor=

View file

@ -0,0 +1,20 @@
{ lib, stdenv, fetchzip }:
stdenv.mkDerivation rec {
pname = "sddm-i3-theme";
version = "1";
src = fetchzip {
url = "http://192.168.1.12/${pname}.tar.gz";
hash = "sha256-587c+T7SflqYshPxRRcVD4xmY2pc4UBw+bYJQm04ZjU=";
};
installPhase = ''
mkdir -p $out/share/sddm/themes/${pname}/
cp -r $src/* $out/share/sddm/themes/${pname}/
'';
meta = {
license = lib.licenses.mit;
platforms = lib.platforms.linux;
};
}

View file

@ -7,11 +7,7 @@ stdenv.mkDerivation rec {
pname = "sddm-i3-theme"; pname = "sddm-i3-theme";
version = "1"; version = "1";
src = fetchzip { src = ../files/sddm-i3-theme;
# lol
url = "http://192.168.1.12/${pname}.tar.gz";
hash = "sha256-WGvjW3Z8TfJhAsbxUyYRKSYFucEwYzTIbpDZsLTPbyo=";
};
installPhase = '' installPhase = ''
mkdir -p $out/share/sddm/themes/${pname}/ mkdir -p $out/share/sddm/themes/${pname}/