[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Lock Screen if lid is closed - KLaptopdaemon
From: Steffen Zieger <kde-devel () steffenspage ! de>
Date: 2004-10-01 7:54:23
Message-ID: 200410010954.25533.kde-devel () steffenspage ! de
[Download RAW message or body]
Hello list,
I've created a patch, to lock the screen, if you close the lid.
The screen is locked probably, but KWallet stops working, if the screen gets
locked through this.
I have to kill kded and everything is working again.
Does anyone have an idea, how to get it fully working?
TIA and HAND,
Steffen
--
Freiheit ist die Freiheit zu sagen, dass zwei und zwei gleich vier ist.
Sobald das gewährleistet ist, ergibt sich alles andere von selbst.
1984 - George Orwell
["KLaptopdaemon_lid_lock_screen.patch" (text/x-diff)]
--- buttons.cpp.orig 2004-01-17 13:57:07.000000000 +0100
+++ buttons.cpp 2004-09-14 08:47:41.000000000 +0200
@@ -53,6 +53,7 @@
lidHibernate(0),
lidShutdown(0),
lidLogout(0),
+ lidLock(0),
lidBrightness(0),
lidValBrightness(0),
lidThrottle(0),
@@ -76,6 +77,7 @@
{
int can_shutdown = 1; // fix me
int can_logout = 1; // fix me
+ int can_lock = 1;
KGlobal::locale()->insertCatalogue("klaptopdaemon"); // For translation of \
klaptopdaemon messages
@@ -144,7 +146,11 @@
lidLogout = new QRadioButton(i18n("Logout"), lidBox);
QToolTip::add( lidShutdown, i18n( "Causes you to be logged out" ) );
}
- if (can_suspend||can_standby||can_hibernate||can_shutdown||can_logout)
+ if (can_lock) {
+ lidLock = new QRadioButton(i18n("Lock Screen"), lidBox);
+ QToolTip::add( lidLock, i18n( "Causes the laptop to lock the screen" ) );
+ }
+ if (can_standby||can_suspend||can_hibernate||can_shutdown||can_logout||can_lock)
lidOff = new QRadioButton(i18n("&Off"), lidBox);
if (can_brightness) {
lidBrightness = new QCheckBox(i18n("Brightness"), lidBox);
@@ -468,16 +474,18 @@
{
if (!apm)
return(lid);
- if (lidHibernate && lidHibernate->isChecked())
- return 3;
if (lidStandby && lidStandby->isChecked())
return 1;
if (lidSuspend && lidSuspend->isChecked())
return 2;
- if (lidLogout && lidLogout->isChecked())
- return 4;
+ if (lidHibernate && lidHibernate->isChecked())
+ return 3;
if (lidShutdown && lidShutdown->isChecked())
return 5;
+ if (lidLogout && lidLogout->isChecked())
+ return 4;
+ if (lidLock && lidLock->isChecked())
+ return 6;
return(0);
}
@@ -502,11 +510,21 @@
{
if (!apm)
return;
+ if (lidStandby) {
+ lidStandby->setChecked(FALSE);
+ } else {
+ if (np == 1) np = 0;
+ }
if (lidSuspend) {
lidSuspend->setChecked(FALSE);
} else {
if (np == 2) np = 0;
}
+ if (lidHibernate) {
+ lidHibernate->setChecked(FALSE);
+ } else {
+ if (np == 3) np = 0;
+ }
if (lidShutdown) {
lidShutdown->setChecked(FALSE);
} else {
@@ -517,15 +535,10 @@
} else {
if (np == 4) np = 0;
}
- if (lidStandby) {
- lidStandby->setChecked(FALSE);
- } else {
- if (np == 1) np = 0;
- }
- if (lidHibernate) {
- lidHibernate->setChecked(FALSE);
+ if (lidLock) {
+ lidLock->setChecked(FALSE);
} else {
- if (np == 3) np = 0;
+ if (np == 6) np = 0;
}
if (lidOff)
lidOff->setChecked(FALSE);
@@ -538,6 +551,7 @@
case 3: lidHibernate->setChecked(TRUE);break;
case 4: lidLogout->setChecked(TRUE);break;
case 5: lidShutdown->setChecked(TRUE);break;
+ case 6: lidLock->setChecked(TRUE);break;
}
if (powerSuspend) {
powerSuspend->setChecked(FALSE);
--- buttons.h.orig 2003-03-12 13:31:28.000000000 +0100
+++ buttons.h 2004-09-14 08:48:42.000000000 +0200
@@ -61,7 +61,7 @@
void setPower( int, int );
QButtonGroup *lidBox;
- QRadioButton *lidStandby, *lidSuspend, *lidOff, *lidHibernate, *lidShutdown, \
*lidLogout; + QRadioButton *lidStandby, *lidSuspend, *lidOff, *lidHibernate, \
*lidShutdown, *lidLogout, *lidLock; QCheckBox *lidBrightness;
QSlider *lidValBrightness;
QCheckBox *lidThrottle;
--- daemon_state.h.orig 2004-09-14 13:19:49.000000000 +0200
+++ daemon_state.h 2004-09-14 13:20:07.000000000 +0200
@@ -69,6 +69,7 @@
bool systemBeep[2];
bool logout[2];
+ bool lock[2];
bool shutdown[2];
bool runCommand[2];
QString runCommandPath[2];
--- laptop_daemon.cpp.orig 2004-09-14 09:58:11.000000000 +0200
+++ laptop_daemon.cpp 2004-09-14 13:38:10.000000000 +0200
@@ -202,6 +202,8 @@
break;
case 5: invokeShutdown();
break;
+ case 6: invokeLock();
+ break;
}
}
if (s.enable_power_button && (power_state = \
laptop_portable::get_button(laptop_portable::PowerButton))) { @@ -534,6 +536,8 @@
invokeStandby();
if (s.logout[t])
invokeLogout();
+ if (s.lock[t])
+ invokeLock();
if (s.shutdown[t])
invokeShutdown();
// notify if we must (must be last since it's synchronous)
@@ -792,6 +796,17 @@
KMessageBox::sorry(0, i18n("Logout failed."));
}
+void laptop_daemon::invokeLock()
+{
+ DCOPClient* client = kapp->dcopClient();
+ if (client)
+ {
+ client->attach();
+ client->send("kdesktop", "KScreensaverIface", "lock()", "");
+ client->detach();
+ }
+}
+
void laptop_daemon::invokeShutdown()
{
bool rc = kapp->requestShutDown(KApplication::ShutdownConfirmNo, \
KApplication::ShutdownTypeHalt, KApplication::ShutdownModeForceNow); @@ -963,6 +978,8 \
@@ break;
case 5: invokeShutdown();
break;
+ case 6: invokeLock();
+ break;
}
} else {
if (button_bright_saved) {
--- laptop_daemon.h.orig 2004-09-14 11:00:36.000000000 +0200
+++ laptop_daemon.h 2004-09-14 11:01:02.000000000 +0200
@@ -108,6 +108,7 @@
void invokeHibernate();
void invokeShutdown();
void invokeLogout();
+ void invokeLock();
void displayPixmap();
void setBlankSaver(bool);
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic