File: xbattery.c

package info (click to toggle)
apmd 3.2.2-15
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 508 kB
  • sloc: ansic: 2,884; makefile: 594; sh: 192
file content (61 lines) | stat: -rw-r--r-- 1,844 bytes parent folder | download | duplicates (7)
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
/*  Copyright (C) Nathan Sidwell 1999 <nathan@acm.org>
 *  $Id: xbattery.c,v 1.1 1999/08/02 20:08:10 apenwarr Exp $
 * 
 *  This file is available under the GNU General Public License.
 *  This is inspired by the xapm application by Rickard E Faith
 * (r.faith@ieee.org). This is just a launcher for a BatteryGauge widget.
 * Read that widget's documentation for use.
 */

/*{{{  includes*/
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/Command.h>
#include "BatteryGauge.h"
#include <apm.h>
/*}}}*/

/*{{{  static XrmOptionDescRec options[] =*/
static XrmOptionDescRec options[] =
{
  {"-delay", "*update", XrmoptionSepArg, NULL},
  {"-update", "*update", XrmoptionSepArg, NULL},
  {"-criticalColor", "*criticalColor", XrmoptionSepArg, NULL},
  {"-lowColor", "*warningColor", XrmoptionSepArg, NULL},
  {"-highColor", "*normalColor", XrmoptionSepArg, NULL},
  {"-chargingColor", "*chargingColor", XrmoptionSepArg, NULL},
  {"-criticalLevel", "*criticalLevel", XrmoptionSepArg, NULL},
  {"-flash", "*flash", XrmoptionSepArg, NULL},
  {"-orientation", "*orientation", XrmoptionSepArg, NULL},
};
/*}}}*/
/*{{{  int main(int argc, char **argv)*/
int main(int argc, char **argv)
{
  XtAppContext context;
  Widget topLevel;
  Widget  gauge;
  
  /*{{{  check APM support*/
  switch(apm_exists())
    {
      case 1:
        fprintf(stderr, "xbattery:No APM support available\n");
        exit(1);
      case 2:
        fprintf(stderr, "xbattery:Obsolete APM support in kernel\n");
        exit(1);
    }
  /*}}}*/
  topLevel = XtAppInitialize(&context, "XBattery",
      options, XtNumber(options),
      &argc, argv, NULL, NULL, 0);

  gauge = XtCreateManagedWidget("gauge",
      batteryGaugeWidgetClass, topLevel, NULL, 0);
  XtRealizeWidget(topLevel);
  XtAppMainLoop(context);
  return 0;
}
/*}}}*/