3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 * @brief Power Manager main file
23 * Process the user options, Daemonize the process, Start Main loop
27 * @addtogroup POWER_MANAGER
30 * @section execution How to execute
31 * # powermanager {options...} <br>
34 * -f --foreground<br>
35 * Run as foreground process<br> <br>
36 * -d --direct<br>
37 * Start without notification<br> <br>
44 #include <sys/types.h>
60 printf("Options: \n");
61 printf(" -f, --foreground Run as foreground process\n");
62 printf(" -d, --direct Start without notification\n");
64 (" -x, --xdpms With LCD-onoff control by x-dpms \n");
73 #define DEFAULT_PID_PATH "/var/run/power-manager.pid"
75 int main(int argc, char *argv[])
78 int runflags = 0; /* run as daemon */
79 unsigned int flags = 0x0; /* 0 : start with noti */
83 static struct option long_options[] = {
84 {"foreground", no_argument, NULL, 'f'},
85 {"direct", no_argument, NULL, 'd'},
86 {"xdpms", no_argument, NULL, 'x'},
90 c = getopt_long(argc, argv, "fdx", long_options, &option_index);
100 flags = flags | WITHOUT_STARTNOTI; /* 0x1 : start without noti */
104 flags = flags | FLAG_X_DPMS; /* 0x2 : X control LCD onoff */
116 if (access(DEFAULT_PID_PATH, F_OK) == 0) { /* pid file exist */
118 ("Check the PM is running. If it isn't, delete \"%s\" and retry.\n",
126 writepid(DEFAULT_PID_PATH);
128 /* this function is main loop, defined in pm_core.c */
131 unlink(DEFAULT_PID_PATH);