summaryrefslogtreecommitdiff
path: root/portland/dapi/generic/commands.c
blob: 57be41ed9a52609059a2e2157d0d5b0fc534d4f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <config.h>

#include <signal.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>

#include <X11/Xlib.h>

#ifdef HAVE_DPMS
#include <X11/extensions/dpms.h>
#endif

#include "commands.h"

static void sigchld( int s )
    {
    int status;
    ( void ) s;
    while( waitpid( -1, &status, WNOHANG ) > 0 )
        ;
    }

int openUrl( const char* url )
    {
    struct sigaction sa, saold;
    sa.sa_handler = sigchld;
    sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
    sigemptyset( &sa.sa_mask );
    sigaction( SIGCHLD, &sa, &saold );
    if( fork() == 0 )
        {
        const char* browser = getenv( "BROWSER" );
        if( browser != NULL )
            execlp( browser, browser, url, NULL );
        execlp( "firefox", "firefox", url, NULL );
        execlp( "mozilla", "mozilla", url, NULL );
        execlp( "netscape", "netscape", url, NULL );
        execlp( "opera", "opera", url, NULL );
        exit( 1 );
        }
    return 1; /* TODO */
    }

int suspendScreensaving( Display* dpy, int suspend )
    {
#ifdef HAVE_DPMS
    if( !DPMSCapable( dpy ))
        return 0;
    if( suspend )
        return DPMSDisable( dpy );
    else
        return DPMSEnable( dpy );
#else
    return 0;
#endif
    }

int mailTo( const char* subject, const char* body, const char* to,
    const char* cc, const char* bcc, const char** attachments, int att_count )
    {
    ( void ) subject;
    ( void ) body;
    ( void ) to;
    ( void ) cc;
    ( void ) bcc;
    ( void ) attachments;
    ( void ) att_count;
    /* TODO */
    return 0;
    }