diff --git a/awesomerc b/awesomerc index 381f4d51..a65bf5d4 100644 --- a/awesomerc +++ b/awesomerc @@ -151,7 +151,7 @@ keys { modkey = {"Mod4"} key = "b" - command = "togglebar" + command = "statusbar_toggle" } key { diff --git a/config.c b/config.c index def470af..67f5f9c5 100644 --- a/config.c +++ b/config.c @@ -463,20 +463,9 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf) awesomeconf->screens[screen].colors_selected[ColFG] = initxcolor(awesomeconf->display, get_phys_screen(awesomeconf->display, screen), cfg_getstr(cfg_colors, "focus_fg")); /* Statusbar */ - tmp = cfg_getstr(cfg_statusbar, "position"); - - if(tmp && !a_strncmp(tmp, "off", 6)) - awesomeconf->screens[screen].statusbar.dposition = BarOff; - else if(tmp && !a_strncmp(tmp, "bottom", 6)) - awesomeconf->screens[screen].statusbar.dposition = BarBot; - else if(tmp && !a_strncmp(tmp, "right", 5)) - awesomeconf->screens[screen].statusbar.dposition = BarRight; - else if(tmp && !a_strncmp(tmp, "left", 4)) - awesomeconf->screens[screen].statusbar.dposition = BarLeft; - else - awesomeconf->screens[screen].statusbar.dposition = BarTop; - - awesomeconf->screens[screen].statusbar.position = awesomeconf->screens[screen].statusbar.dposition; + awesomeconf->screens[screen].statusbar.position = + awesomeconf->screens[screen].statusbar.dposition = + get_statusbar_position_from_str(cfg_getstr(cfg_statusbar, "position")); /* Layouts */ awesomeconf->screens[screen].nlayouts = cfg_size(cfg_layouts, "layout"); diff --git a/statusbar.c b/statusbar.c index 02a6d025..46980554 100644 --- a/statusbar.c +++ b/statusbar.c @@ -276,8 +276,22 @@ updatebarpos(Display *disp, Statusbar statusbar, Padding *padding) while(XCheckMaskEvent(disp, EnterWindowMask, &ev)); } +int +get_statusbar_position_from_str(const char * pos) +{ + if(!a_strncmp(pos, "off", 3)) + return BarOff; + else if(!a_strncmp(pos, "bottom", 6)) + return BarBot; + else if(!a_strncmp(pos, "right", 5)) + return BarRight; + else if(!a_strncmp(pos, "left", 4)) + return BarLeft; + return BarTop; +} + void -uicb_togglebar(awesome_config *awesomeconf, +uicb_statusbar_toggle(awesome_config *awesomeconf, int screen, const char *arg __attribute__ ((unused))) { @@ -289,9 +303,19 @@ uicb_togglebar(awesome_config *awesomeconf, arrange(awesomeconf, screen); } +void +uicb_statusbar_set_position(awesome_config *awesomeconf, + int screen, + const char *arg) +{ + awesomeconf->screens[screen].statusbar.dposition = + awesomeconf->screens[screen].statusbar.position = + get_statusbar_position_from_str(arg); + updatebarpos(awesomeconf->display, awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding); +} void -uicb_setstatustext(awesome_config *awesomeconf, int screen, const char *arg) +uicb_statusbar_set_text(awesome_config *awesomeconf, int screen, const char *arg) { if(!arg) return; diff --git a/statusbar.h b/statusbar.h index b8156233..1c3316dd 100644 --- a/statusbar.h +++ b/statusbar.h @@ -26,10 +26,12 @@ void initstatusbar(Display *, int, Statusbar *, Cursor, XftFont *, Layout *, int, Padding *); void drawstatusbar(awesome_config *, int); +int get_statusbar_position_from_str(const char *); void updatebarpos(Display *, Statusbar, Padding *); -UICB_PROTO(uicb_togglebar); -UICB_PROTO(uicb_setstatustext); +UICB_PROTO(uicb_statusbar_toggle); +UICB_PROTO(uicb_statusbar_set_position); +UICB_PROTO(uicb_statusbar_set_text); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 diff --git a/uicb.c b/uicb.c index 48576923..4bac6404 100644 --- a/uicb.c +++ b/uicb.c @@ -67,9 +67,9 @@ const NameFuncLink UicbList[] = { /* awesome.c */ {"quit", uicb_quit}, /* statusbar.c */ - {"togglebar", uicb_togglebar}, - /* config.c */ - {"setstatustext", uicb_setstatustext}, + {"statusbar_toggle", uicb_statusbar_toggle}, + {"statusbar_set_position", uicb_statusbar_set_position}, + {"statusbar_set_text", uicb_statusbar_set_text}, /* mouse.c */ {"client_movemouse", uicb_client_movemouse}, {"client_resizemouse", uicb_client_resizemouse},