logind: optionally handle power, sleep and lid switch events
This takes handling of chassis power and sleep keys as well as the lid switch over from acpid. This logic is enabled by default for power and sleep keys, but not for the lid switch. If a graphical session is in the foreground no action is taken under the assumption that the graphical session does this.
This commit is contained in:
@@ -5639,3 +5639,25 @@ bool in_initrd(void) {
|
||||
|
||||
return saved;
|
||||
}
|
||||
|
||||
void warn_melody(void) {
|
||||
int fd;
|
||||
|
||||
fd = open("/dev/console", O_WRONLY|O_CLOEXEC|O_NOCTTY);
|
||||
if (fd < 0)
|
||||
return;
|
||||
|
||||
/* Yeah, this is synchronous. Kinda sucks. Bute well... */
|
||||
|
||||
ioctl(fd, KIOCSOUND, (int)(1193180/440));
|
||||
usleep(125*USEC_PER_MSEC);
|
||||
|
||||
ioctl(fd, KIOCSOUND, (int)(1193180/220));
|
||||
usleep(125*USEC_PER_MSEC);
|
||||
|
||||
ioctl(fd, KIOCSOUND, (int)(1193180/220));
|
||||
usleep(125*USEC_PER_MSEC);
|
||||
|
||||
ioctl(fd, KIOCSOUND, 0);
|
||||
close_nointr_nofail(fd);
|
||||
}
|
||||
|
||||
@@ -513,4 +513,7 @@ int can_sleep(const char *type);
|
||||
bool is_valid_documentation_url(const char *url);
|
||||
|
||||
bool in_initrd(void);
|
||||
|
||||
void warn_melody(void);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user