static void init_commands(void) { attr_init(); bmap_init(); fadvise_init(); file_init(); freeze_init(); fsync_init(); getrusage_init(); help_init(); imap_init(); inject_init(); madvise_init(); mincore_init(); mmap_init(); open_init(); parent_init(); pread_init(); prealloc_init(); fiemap_init(); pwrite_init(); quit_init(); resblks_init(); sendfile_init(); shutdown_init(); truncate_init(); }
void cmd_chshut(int argc, char *argv[]) { struct shutdown_trigger *st; struct shutdown_action *sa; char path[PATH_MAX]; parse_chshut_options(argc, argv); if (argc < 2) { ERR("No trigger specified"); print_help_hint_exit(); } shutdown_init(); st = shutdown_trigger_get(argv[1]); if (st == &shutdown_trigger_panic || st == &shutdown_trigger_restart) ERR_EXIT("Please use \"service dumpconf\" for " "configuring the %s trigger", st->name); if (argc < 3) { ERR("No action specified"); print_help_hint_exit(); } sa = shutdown_action_get(argv[2]); if (sa == &shutdown_action_vmcmd) { vmcmd_set(st, argc, argv); } else if (argc != 3) { ERR("Too many parameters specified"); print_help_hint_exit(); } sprintf(path, "shutdown_actions/%s", st->name_sysfs); if (write_str_errno(argv[2], path)) ERR_EXIT_ERRNO("Could not set \"%s\"", path); }
void cmd_lsshut(int argc, char *argv[]) { int i; parse_lsshut_options(argc, argv); shutdown_init(); printf("Trigger Action\n"); printf("========================\n"); for (i = 0; shutdown_trigger_vec[i]; i++) { if (!shutdown_trigger_vec[i]->available) continue; shutdown_trigger_print(shutdown_trigger_vec[i]); } }
void init_tabletwm() { memset(&key_win, 0, sizeof(key_win)); memset(&shutdown_win, 0, sizeof(shutdown_win)); xcb_void_cookie_t void_cookie; xcb_intern_atom_cookie_t atom_cookie[TWM_ATOM_LAST_VALUE]; uint32_t v[] = {XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_PROPERTY_CHANGE}; int i; char *a_atoms[TWM_ATOM_LAST_VALUE] = { "WM_SIZE_HINTS", "WM_NORMAL_HINTS", "WM_PROTOCOLS", "WM_DELETE_WINDOW", "WM_TRANSIENT_FOR", "_NET_SUPPORTING_WM_CHECK", "_NET_WM_NAME", "_NET_SUPPORTED", "_NET_WM_WINDOW_TYPE", "_NET_WM_WINDOW_TYPE_DESKTOP", "_NET_WM_WINDOW_TYPE_DOCK", "_NET_WM_WINDOW_TYPE_TOOLBAR", "_NET_WM_WINDOW_TYPE_MENU", "_NET_WM_WINDOW_TYPE_UTILITY", "_NET_WM_WINDOW_TYPE_SPLASH", "_NET_WM_WINDOW_TYPE_DIALOG", "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", "_NET_WM_WINDOW_TYPE_POPUP_MENU", "_NET_WM_WINDOW_TYPE_TOOLTIP", "_NET_WM_WINDOW_TYPE_NOTIFICATION", "_NET_WM_WINDOW_TYPE_COMBO", "_NET_WM_WINDOW_TYPE_DND", "_NET_WM_WINDOW_TYPE_NORMAL", "_NET_WM_ALLOWED_ACTIONS", "_NET_WM_ACTION_MOVE", "_NET_WM_ACTION_RESIZE", "_NET_WM_ACTION_MINIMIZE", "_NET_WM_ACTION_SHADE", "_NET_WM_ACTION_STICK", "_NET_WM_ACTION_MAXIMIZE_HORZ", "_NET_WM_ACTION_MAXIMIZE_VERT", "_NET_WM_ACTION_FULLSCREEN", "_NET_WM_ACTION_CHANGE_DESKTOP", "_NET_WM_ACTION_CLOSE", "_NET_WM_ACTION_ABOVE", "_NET_WM_ACTION_BELOW", "WM_CLASS", "WM_STATE", "_NET_ACTIVE_WINDOW", "WM_HINTS", "_XKB_RULES_NAMES", }; init_load_config(); wincache_init(); conn = xcb_connect(0, 0); assert(conn); scr = xcb_setup_roots_iterator(xcb_get_setup(conn)).data; width = scr->width_in_pixels; height = scr->height_in_pixels; // reserve the bottom part for the 1pixel-height, collapsed menu bar xcb_change_window_attributes(conn, scr->root, XCB_CW_EVENT_MASK, v); xcb_depth_iterator_t depth_iter; xcb_visualid_t root_visual = { 0 }; visual_type = NULL; for (depth_iter = xcb_screen_allowed_depths_iterator (scr); depth_iter.rem; xcb_depth_next (&depth_iter)) { xcb_visualtype_iterator_t visual_iter; visual_iter = xcb_depth_visuals_iterator (depth_iter.data); for (; visual_iter.rem; xcb_visualtype_next (&visual_iter)) { if (scr->root_visual == visual_iter.data->visual_id) { visual_type = visual_iter.data; break; } } } /* get atoms */ for(i=0; i < TWM_ATOM_LAST_VALUE; i++) { atom_cookie[i] = xcb_intern_atom_unchecked(conn, 0, strlen(a_atoms[i]), a_atoms[i]); }; xcb_flush(conn); xcb_intern_atom_reply_t *atom_reply; for(i=0; i < TWM_ATOM_LAST_VALUE; i++) { atom_reply = xcb_intern_atom_reply(conn, atom_cookie[i], 0), atoms[i] = atom_reply->atom; free(atom_reply); }; xcb_change_property(conn, XCB_PROP_MODE_REPLACE, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM_WM_DELETE_WINDOW]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_DESKTOP]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_DOCK]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_TOOLBAR]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_MENU]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED] , XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_UTILITY]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_SPLASH]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_DIALOG]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_DROPDOWN_MENU]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_POPUP_MENU]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_TOOLTIP]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_NOTIFICATION]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_COMBO]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_DND]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_NORMAL]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ALLOWED_ACTIONS]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_MOVE]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_RESIZE]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_MINIMIZE]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_SHADE]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_STICK]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_MAXIMIZE_HORZ]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_MAXIMIZE_VERT]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_FULLSCREEN]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_CHANGE_DESKTOP]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_CLOSE]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_ABOVE]); xcb_change_property(conn, XCB_PROP_MODE_APPEND, scr->root, atoms[TWM_ATOM__NET_SUPPORTED], XCB_ATOM_ATOM, 32, 1, &atoms[TWM_ATOM__NET_WM_ACTION_BELOW]); // This window contains the menu and the virtual keyboard (when showed) // It is also used to ensure that the window manager is recognized as an Extended Window Manager Hints WM // By default it occupies one pixel at the bottom of the screen, to allow to detect when the mouse is moved to the bottom xcb_get_property_cookie_t kbd_info_cookie; xcb_get_property_reply_t *kbd_info; kbd_info_cookie = xcb_get_property(conn, 0, scr->root, atoms[TWM__XKB_RULES_NAMES], XCB_ATOM_STRING, 0, 1024); key_win.window = xcb_generate_id(conn); uint32_t values[1] = {XCB_EVENT_MASK_EXPOSURE|XCB_EVENT_MASK_BUTTON_RELEASE|XCB_EVENT_MASK_BUTTON_PRESS|XCB_EVENT_MASK_ENTER_WINDOW|XCB_EVENT_MASK_LEAVE_WINDOW}; void_cookie=xcb_create_window_checked (conn, XCB_COPY_FROM_PARENT, key_win.window, scr->root, 0, height-1, width, 1, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, scr->root_visual, XCB_CW_EVENT_MASK, values); xcb_flush(conn); kbd_info = xcb_get_property_reply(conn, kbd_info_cookie, 0); if (kbd_info!=NULL) { if (kbd_info->length>0) { char *p=((char *)(xcb_get_property_value(kbd_info))); int counter=0; int len, max; max=xcb_get_property_value_length(kbd_info); char *end=p+max; do { len = strnlen(p, max); if (*p!=0) { xkb_names[counter++] = strdup(p); } p+=len+1; max-=len+1; } while ((p < end) && (counter < 5)); } free(kbd_info); } if (xcb_request_check(conn, void_cookie)) { printf("Can't create the fake window\n"); } else { menuwin_init(); } shutdown_init(); }