i3lock issue

asked 2014-12-31 02:30:39 +0000

Nietzsche gravatar image

updated 2014-12-31 02:34:02 +0000

I made a little C program to act as shutdown/reboot/lock menu (and to have fun) that works perfectly when called in a running term emulator, but the lock function does not when launched like this: "urxvt -e program". Any idea why?

#include <ncurses.h>
#include <string.h>
#include <unistd.h>

int main()
    initscr(); keypad(stdscr, TRUE); noecho(); curs_set(0);
    int i, choice = 0, c = 0;
    const char *options[]=

    for(i = 0; options[i]; ++i)
        mvaddstr(i, 0, options[i]);

    move(0, 0);
        mvchgat(choice, 0, strlen(options[choice]), A_NORMAL, 0, NULL);
        if(c == KEY_DOWN && choice < 2)
        else if(c == KEY_UP && choice)
        mvchgat(choice, 0, strlen(options[choice]), A_REVERSE, 0, NULL);
    while((c = getch()) != '\n');

        case 0:
            system("mpd --kill && systemctl poweroff");

        case 1:
            system("mpd --kill && systemctl reboot");

        case 2:
    return 0;

It "works" if I don't close the program, e.g. add something like a getch() before the return. i don't understand why since system and i3lock fork.

Content of lock.sh if it can help:


import -window root $IMAGE
convert $IMAGE -blur '0x5' $IMAGE
i3lock -i $IMAGE
edit retag flag offensive close merge delete