コード例 #1
0
ファイル: main.c プロジェクト: yoook/LaptopControl
int main (int argc, char **argv)
{
    int c;
    int i = 0;
    int short_output=0;


    opterr = 0;
    while ((c = getopt (argc, argv, "sk:Bb:Tt:Rr:")) != -1)
    {
        i = 1;
        switch (c)
        {
        case 's':
            short_output = 1;
            break;
        case 'k':
            set_kbd_backlight(optarg);
            break;
        case 'B':
            if (short_output)
            {
                printf("%d", (get_battery_care_limiter()==0) ? 100 : get_battery_care_limiter());
            }
            else
            {
                printf("Battery care limiter is set to %d%%.\n", (get_battery_care_limiter()==0) ? 100 : get_battery_care_limiter());
            }
            break;
        case 'b':
            set_battery_care_limiter(optarg);
            break;
        case 'T':
            if(short_output)
            {
                printf("%s", get_thermal_control());
            }
            else
            {
                printf("Thermal control is set to %s.\n", get_thermal_control());
            }
            break;
        case 't':
            set_thermal_control(optarg);
            break;
        case 'R':
            printf("%d", get_lid_resume());
            break;
        case 'r':
            set_lid_resume(optarg);
            break;
        case '?':
            if (optopt == 'b' || optopt == 'k' || optopt == 't')
                fprintf (stderr, "Option -%c requires an argument.\n", optopt);
            else if (isprint (optopt))
                fprintf (stderr, "Unknown option `-%c'.\n", optopt);
            else
                fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
            return 1;
        default:
            abort ();
        }
    }
    if ( i == 0 )
    {
        print_usage();
      }

  return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: 183amir/LaptopControl
int main (int argc, char **argv)
{
    int c;
    int i = 0;


    opterr = 0;
    while ((c = getopt (argc, argv, "k:Bb:Tt:")) != -1)
    {
        i = 1;
        switch (c)
        {
        case 'k':
            set_kbd_backlight(optarg);
            break;
        case 'B':
            printf("Battery care limiter set to %d%%\n", (get_battery_care_limiter()==0) ? 100 : get_battery_care_limiter());
            break;
        case 'b':
            set_battery_care_limiter(optarg);
            break;
        case 'T':
            printf("Thermal control is set to %s.\n", get_thermal_control());
            break;
        case 't':
            set_thermal_control(optarg);
            break;
        case '?':
            if (optopt == 'b' || optopt == 'k' || optopt == 't')
                fprintf (stderr, "Option -%c requires an argument.\n", optopt);
            else if (isprint (optopt))
                fprintf (stderr, "Unknown option `-%c'.\n", optopt);
            else
                fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
            return 1;
        default:
            abort ();
        }
    }
    if ( i == 0 )
    {
        printf("Usage: LaptopControl [-b percentage] [-B] -[k mode]\n"
                "-b <percentage>: set battery care limiter to <percentage> percent. Allowed values: 50, 80, 100(=0)\n"
                "-B: Print battery care limiter value. 0 == 100\n"
                "-t <mode>: set thermal control (fan's speed).\n"
                "  mode: 's' | 'silent'\n"
                "        'b' | 'balanced'\n"
                "        'p' | 'performance'\n"
                "-T: Print current thermal control (fan's speed).\n"
                "-k <mode>: set keyboard backlight status and timeout:\n"
                "  mode: 'e' | 'endless' for endless backlight, if dark \n"
                "        'n' | 'off' for no backlight, \n"
                "        't' | 't1' | 't2' | 't3' | 'timeout' for backlight with timout after\n"
                "                       keypress, if dark. Different timeouts can be selected\n"
                "                       with 't<n>'\n"
                "                              't1': 10s\n"
                "                              't2': 30 s\n"
                "                                  't3' | 't' | 'timeout': 60s\n");
      }

  return 0;
}