Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Mobile
Commits
1101599e
Commit
1101599e
authored
Feb 10, 2022
by
Devin Lin
🎨
Browse files
quicksettings: Add caffeine quicksetting
parent
1f23de45
Pipeline
#135994
passed with stages
in 57 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
quicksettings/CMakeLists.txt
View file @
1101599e
...
...
@@ -2,4 +2,5 @@
# SPDX-License-Identifier: GPL-2.0-or-later
plasma_install_package
(
airplanemode org.kde.plasma.airplanemode quicksettings
)
plasma_install_package
(
caffeine org.kde.plasma.caffeine quicksettings
)
add_subdirectory
(
nightcolor
)
quicksettings/caffeine/contents/ui/main.qml
0 → 100644
View file @
1101599e
/*
* SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
import
org
.
kde
.
plasma
.
private
.
mobileshell
1.0
as
MobileShell
import
org
.
kde
.
plasma
.
core
2.0
as
PlasmaCore
MobileShell.QuickSetting
{
text
:
i18n
(
"
Caffeine
"
)
icon
:
"
system-suspend-hibernate
"
status
:
enabled
?
i18n
(
"
Tap to disable sleep suspension
"
)
:
i18n
(
"
Tap to suspend sleep
"
)
enabled
:
false
PlasmaCore.DataSource
{
id
:
pmSource
engine
:
"
powermanagement
"
connectedSources
:
sources
onSourceAdded
:
{
disconnectSource
(
source
);
connectSource
(
source
);
}
onSourceRemoved
:
{
disconnectSource
(
source
);
}
}
property
int
cookie1
:
-
1
property
int
cookie2
:
-
1
function
toggle
()
{
let
inhibit
=
!
enabled
;
const
service
=
pmSource
.
serviceForSource
(
"
PowerDevil
"
);
if
(
inhibit
)
{
const
reason
=
i18n
(
"
Plasma Mobile has enabled system-wide inhibition
"
);
const
op1
=
service
.
operationDescription
(
"
beginSuppressingSleep
"
);
op1
.
reason
=
reason
;
const
op2
=
service
.
operationDescription
(
"
beginSuppressingScreenPowerManagement
"
);
op2
.
reason
=
reason
;
const
job1
=
service
.
startOperationCall
(
op1
);
job1
.
finished
.
connect
(
job
=>
{
cookie1
=
job
.
result
;
});
const
job2
=
service
.
startOperationCall
(
op2
);
job2
.
finished
.
connect
(
job
=>
{
cookie2
=
job
.
result
;
});
}
else
{
const
op1
=
service
.
operationDescription
(
"
stopSuppressingSleep
"
);
op1
.
cookie
=
cookie1
;
const
op2
=
service
.
operationDescription
(
"
stopSuppressingScreenPowerManagement
"
);
op2
.
cookie
=
cookie2
;
const
job1
=
service
.
startOperationCall
(
op1
);
job1
.
finished
.
connect
(
job
=>
{
cookie1
=
-
1
;
});
const
job2
=
service
.
startOperationCall
(
op2
);
job2
.
finished
.
connect
(
job
=>
{
cookie2
=
-
1
;
});
}
enabled
=
inhibit
;
}
}
quicksettings/caffeine/metadata.desktop
0 → 100644
View file @
1101599e
# SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
# SPDX-License-Identifier: GPL-2.0-or-later
[Desktop Entry]
Name=Caffeine
Icon=system-suspend-hibernate
Type=Service
X-KDE-ServiceTypes=KPackage/GenericQML
X-KDE-PluginInfo-Author=Devin Lin
X-KDE-PluginInfo-Email=devin@kde.org
X-KDE-PluginInfo-Name=org.kde.plasma.caffeine
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=https://kde.org
X-KDE-PluginInfo-License=GPL
Devin Lin
🎨
@devinlin
mentioned in issue
#82 (closed)
·
Feb 11, 2022
mentioned in issue
#82 (closed)
mentioned in issue #82
Toggle commit list
Devin Lin
🎨
@devinlin
mentioned in issue
#152 (closed)
·
Feb 11, 2022
mentioned in issue
#152 (closed)
mentioned in issue #152
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment