Skip to content

Also pass XF86 Power Off and Power Down keys through when using --pass-media-keys #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 21, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions i3lock.1
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ Note that this number is zero indexed. The ordering is dependent on libxinerama.
Captures the screen and blurs it using the given sigma (radius).
Images may still be overlaid over the blurred screenshot.

.TP
.B \-m, \-\-pass-media-keys
Allow the following keys to be used while the screen is locked by passing them through:
XF86AudioPlay, XF86AudioPause, XF86AudioStop, XF86AudioPrev, XF86AudioNext, XF86AudioMute, XF86AudioLowerVolume, XF86AudioRaiseVolume, XF86MonBrightnessUp, XF86MonBrightnessDown.

.TP
.B \-\-indicator
Forces the indicator to always be visible, instead of only showing on activity.
Expand Down Expand Up @@ -169,6 +164,21 @@ Displays the clock. \-\-force\-clock also displays the clock when there's indica
.B \-\-composite
Some compositors have problems with i3lock trying to render over them, so this argument is disabled by default. However, some will work properly with it, so it's been left enabled.

.TP
.B \-m, \-\-pass-media-keys
Allow the following keys to be used while the screen is locked by passing them through:
XF86AudioPlay, XF86AudioPause, XF86AudioStop, XF86AudioPrev, XF86AudioNext, XF86AudioMute, XF86AudioLowerVolume, XF86AudioRaiseVolume.

.TP
.B \-s, \-\-pass-screen-keys
Allow the following keys to be used while the screen is locked by passing them through:
XF86MonBrightnessUp, XF86MonBrightnessDown.

.TP
.B \-p, \-\-pass-power-keys
Allow the following keys to be used while the screen is locked by passing them through:
XF86PowerDown, XF86PowerOff.

.TP
.B \-\-insidevercolor=rrggbbaa
Sets the interior circle color while the password is being verified.
Expand Down
45 changes: 36 additions & 9 deletions i3lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ bool tile = false;
bool ignore_empty_password = false;
bool skip_repeated_empty_password = false;
bool pass_media_keys = false;
bool pass_screen_keys = false;
bool pass_power_keys = false;

// for the rendering thread, so we can clean it up
pthread_t draw_thread;
Expand Down Expand Up @@ -654,6 +656,7 @@ static void handle_key_press(xcb_key_press_event_t *event) {
#else
n = xkb_keysym_to_utf8(ksym, buffer, sizeof(buffer));
#endif

// media keys
if (pass_media_keys) {
switch(ksym) {
Expand All @@ -665,13 +668,31 @@ static void handle_key_press(xcb_key_press_event_t *event) {
case XKB_KEY_XF86AudioMute:
case XKB_KEY_XF86AudioLowerVolume:
case XKB_KEY_XF86AudioRaiseVolume:
xcb_send_event(conn, true, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, (char *)event);
return;
}
}

// screen keys
if (pass_screen_keys) {
switch(ksym) {
case XKB_KEY_XF86MonBrightnessUp:
case XKB_KEY_XF86MonBrightnessDown:
xcb_send_event(conn, true, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, (char *)event);
return;
}
}

// power keys
if (pass_power_keys) {
switch(ksym) {
case XKB_KEY_XF86PowerDown:
case XKB_KEY_XF86PowerOff:
xcb_send_event(conn, true, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, (char *)event);
return;
}
}

// return/enter/etc
switch (ksym) {
case XKB_KEY_j:
Expand Down Expand Up @@ -1362,7 +1383,7 @@ int main(int argc, char *argv[]) {
{"inactivity-timeout", required_argument, NULL, 'I'},
{"show-failed-attempts", no_argument, NULL, 'f'},

/* options for unlock indicator colors */
// options for unlock indicator colors
{"insidevercolor", required_argument, NULL, 300},
{"insidewrongcolor", required_argument, NULL, 301},
{"insidecolor", required_argument, NULL, 302},
Expand Down Expand Up @@ -1391,8 +1412,12 @@ int main(int argc, char *argv[]) {
{"radius", required_argument, NULL, 402},
{"ring-width", required_argument, NULL, 403},

// alignment
// pass keys
{"pass-media-keys", no_argument, NULL, 'm'},
{"pass-screen-keys", no_argument, NULL, 's'},
{"pass-power-keys", no_argument, NULL, 'p'},

// alignment
{"time-align", required_argument, NULL, 500},
{"date-align", required_argument, NULL, 501},
{"verif-align", required_argument, NULL, 502},
Expand All @@ -1402,7 +1427,6 @@ int main(int argc, char *argv[]) {
{"greeter-align", required_argument, NULL, 506},

// string stuff

{"timestr", required_argument, NULL, 510},
{"datestr", required_argument, NULL, 511},
{"veriftext", required_argument, NULL, 512},
Expand All @@ -1414,7 +1438,6 @@ int main(int argc, char *argv[]) {
{"greetertext", required_argument, NULL, 518},

// fonts

{"time-font", required_argument, NULL, 520},
{"date-font", required_argument, NULL, 521},
{"verif-font", required_argument, NULL, 522},
Expand All @@ -1423,7 +1446,6 @@ int main(int argc, char *argv[]) {
{"greeter-font", required_argument, NULL, 525},

// text size

{"timesize", required_argument, NULL, 530},
{"datesize", required_argument, NULL, 531},
{"verifsize", required_argument, NULL, 532},
Expand Down Expand Up @@ -1463,7 +1485,6 @@ int main(int argc, char *argv[]) {
{"redraw-thread", no_argument, NULL, 900},
{"refresh-rate", required_argument, NULL, 901},
{"composite", no_argument, NULL, 902},
{"pass-media-keys", no_argument, NULL, 'm'},

/* slideshow options */
{"slideshow-interval", required_argument, NULL, 903},
Expand Down Expand Up @@ -1563,6 +1584,15 @@ int main(int argc, char *argv[]) {
blur = true;
blur_sigma = atoi(optarg);
break;
case 'm':
pass_media_keys = true;
break;
case 's':
pass_screen_keys = true;
break;
case 'p':
pass_power_keys = true;
break;
// begin colors
#define parse_color(color)\
arg = optarg;\
Expand Down Expand Up @@ -1993,9 +2023,6 @@ int main(int argc, char *argv[]) {
case 904:
slideshow_random_selection = true;
break;
case 'm':
pass_media_keys = true;
break;
case 999:
debug_mode = true;
break;
Expand Down