Permalink
Browse files

Added option in rc.conf to select which monitor the bar is on

  • Loading branch information...
1 parent 8be9dd9 commit 46f19562586be4a7271f816645e93898e846185d @moetunes committed Oct 16, 2012
Showing with 54 additions and 41 deletions.
  1. +4 −1 ChangeLog
  2. +7 −7 bar.c
  3. +3 −3 config.h
  4. +1 −1 readkeysapps.c
  5. +10 −4 readrc.c
  6. +3 −3 sample.apps.conf
  7. +13 −12 sample.key.conf
  8. +5 −2 sample.rc.conf
  9. +8 −8 snapwm.c
View
5 ChangeLog
@@ -1,5 +1,8 @@
+16/10/12
+ Added option in rc.conf to select monitor bar is on
+
11/10/12
- Changed the DEFAULT_MODE line in rc.conf
+ Changed the DEFAULTMODE line in rc.conf
to set the default mode for each desktop
10/10/12
View
14 bar.c
@@ -1,4 +1,4 @@
-// bar.c [ 0.7.0 ]
+// bar.c [ 0.7.1 ]
static void draw_numopen(unsigned int cd, unsigned int gc);
static Drawable area_sb;
@@ -32,18 +32,18 @@ void setup_status_bar() {
void status_bar() {
unsigned int i, y;
- y = (topbar == 0) ? 0 : desktops[0].h+bdw;
+ y = (topbar == 0) ? 0 : desktops[barmon].h+bdw;
sb_width = 0;
for(i=0;i<DESKTOPS;++i) {
- sb_bar[i].sb_win = XCreateSimpleWindow(dis, root, sb_width, y,
+ sb_bar[i].sb_win = XCreateSimpleWindow(dis, root, desktops[barmon].x+sb_width, y,
sb_bar[i].width-2,sb_height,2,theme[3].barcolor,theme[0].barcolor);
XSelectInput(dis, sb_bar[i].sb_win, ButtonPressMask|EnterWindowMask|LeaveWindowMask);
XMapWindow(dis, sb_bar[i].sb_win);
sb_width += sb_bar[i].width;
}
- sb_area = XCreateSimpleWindow(dis, root, sb_desks, y,
- desktops[0].w-(sb_desks+2),sb_height,2,theme[3].barcolor,theme[1].barcolor);
+ sb_area = XCreateSimpleWindow(dis, root, desktops[barmon].x+sb_desks, y,
+ desktops[barmon].w-(sb_desks+2),sb_height,2,theme[3].barcolor,theme[1].barcolor);
XSelectInput(dis, sb_area, ButtonPressMask|ExposureMask|EnterWindowMask|LeaveWindowMask);
XMapWindow(dis, sb_area);
@@ -62,13 +62,13 @@ void toggle_bar() {
if(STATUS_BAR == 0) {
if(has_bar == 0) {
show_bar = 1;
- desktops[0].h += sb_height+4;
+ desktops[barmon].h += sb_height+4;
for(i=0;i<DESKTOPS;++i) XUnmapWindow(dis,sb_bar[i].sb_win);
XUnmapWindow(dis, sb_area);
has_bar = 1;
} else {
show_bar = 0;
- desktops[0].h -= sb_height+4;
+ desktops[barmon].h -= sb_height+4;
for(i=0;i<DESKTOPS;++i) XMapWindow(dis, sb_bar[i].sb_win);
XMapWindow(dis, sb_area);
has_bar = 0;
View
6 config.h
@@ -9,9 +9,9 @@
#define FONTS_ERROR 1 /* 1=Don't 0=Print errors about missing fonts */
static const char *defaultdesktopnames[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", };
-static const char *defaultbarcolor[] = { "#ff0000", "#00ff00", "#0000ff", "#000000", };
-static const char *defaulttextcolor[] = { "#000000", "#ffffff", "#ffffff", "#ffff00", "#ff00ff", "#f0f0f0", "#0f0f0f", "#000000", "#000000", "#000000", };
-static const char *defaultwincolor[] = { "#ff0000", "#00ff00", };
+static const char *defaultbarcolor[] = { "#665522", "#002030", "#003040", "#001020", };
+static const char *defaulttextcolor[] = { "#002030", "#002030", "#665544", "#998866", "#887733", "#999999", "#558844", "#aa6622", "#ffffff", "#003040", };
+static const char *defaultwincolor[] = { "#443311", "#002030", };
static const char *defaultmodename[] = { "[0]", "[1]", "[2]", "[3]", "[4]", };
static const char defaultfontlist[] = "-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*";
View
2 readkeysapps.c
@@ -1,4 +1,4 @@
-/* readkeysapps.c [ 0.7.0 ] */
+/* readkeysapps.c [ 0.7.1 ] */
void read_keys_file() {
FILE *keyfile ;
View
14 readrc.c
@@ -1,4 +1,4 @@
-// readrc.c [ 0.7.0 ]
+// readrc.c [ 0.7.1 ]
/* *********************** Read Config File ************************ */
void read_rcfile() {
@@ -41,6 +41,12 @@ void read_rcfile() {
} else if(strstr(buffer, "DESKTOPS" ) != NULL) {
DESKTOPS = atoi(strstr(buffer, " ")+1);
if(DESKTOPS > 10) DESKTOPS = 10;
+ } else if(strstr(buffer, "BAR_MONITOR" ) != NULL) {
+ i = atoi(strstr(buffer, " ")+1);
+ if(i < num_screens && i >= 0) {
+ barmon = i;
+ init_desks();
+ }
} else if(strstr(buffer, "UF_WIN_ALPHA" ) != NULL) {
ufalpha = atoi(strstr(buffer, " ")+1);
} else if(strstr(buffer, "BORDERWIDTH" ) != NULL) {
@@ -209,7 +215,7 @@ void update_config() {
XUngrabButton(dis, AnyButton, AnyModifier, root);
if(font.fontset) XFreeFontSet(dis, font.fontset);
read_rcfile();
- y = (topbar == 0) ? 0 : desktops[0].h+bdw;
+ y = (topbar == 0) ? 0 : desktops[barmon].h+bdw;
if(DESKTOPS < old_desktops) {
save_desktop(current_desktop);
Arg a = {.i = DESKTOPS-1};
@@ -237,12 +243,12 @@ void update_config() {
sb_width = 0;
for(i=0;i<DESKTOPS;++i) {
XSetWindowBorder(dis,sb_bar[i].sb_win,theme[3].barcolor);
- XMoveResizeWindow(dis, sb_bar[i].sb_win, sb_width, y,sb_bar[i].width-2,sb_height);
+ XMoveResizeWindow(dis, sb_bar[i].sb_win, desktops[barmon].x+sb_width, y,sb_bar[i].width-2,sb_height);
sb_width += sb_bar[i].width;
}
XSetWindowBorder(dis,sb_area,theme[3].barcolor);
XSetWindowBackground(dis, sb_area, theme[1].barcolor);
- XMoveResizeWindow(dis, sb_area, sb_desks, y, desktops[0].w-(sb_desks+4)+bdw,sb_height);
+ XMoveResizeWindow(dis, sb_area, desktops[barmon].x+sb_desks, y, desktops[barmon].w-(sb_desks+4)+bdw,sb_height);
XGetWindowAttributes(dis, sb_area, &attr);
total_w = attr.width;
if(area_sb != 0) {
View
6 sample.apps.conf
@@ -1,10 +1,10 @@
# USAGE :
# DESKTOP wm_class;desktop number;0=follow 1=don't;
-
+#
# DESKTOP Thunar;2;0;
# DESKTOP MPlayer;4;1;
-
+#
# USAGE :
# POSITION wm_class;x;y;width;height;
-
+#
# POSITION Thunar;100;100;800;400;
View
25 sample.key.conf
@@ -1,9 +1,9 @@
# Possible Mods are Alt, CtrlAlt, ShftAlt, Super, ShftSuper, CtrlSuper, ALTSuper
-
+#
# Set external commands ; use with spawn
CMD dmenucmd;dmenu_run;-i;-nb;#666622;-nf;white;NULL;
CMD xtermcmd;xterm;NULL;
-
+#
KEY Alt;1;change_desktop;0;
KEY Alt;2;change_desktop;1;
KEY Alt;3;change_desktop;2;
@@ -14,10 +14,10 @@ KEY Alt;7;change_desktop;6;
KEY Alt;8;change_desktop;7;
KEY Alt;9;change_desktop;8;
KEY Alt;F10;change_desktop;9;
-
+#
KEY Super;Right;rotate_desktop;1;
KEY Super;Left;rotate_desktop;-1;
-
+#
# Send an app to another desktop and follow it
KEY ShftAlt;1;follow_client_to_desktop;0;
KEY ShftAlt;2;follow_client_to_desktop;1;
@@ -29,7 +29,7 @@ KEY ShftAlt;7;follow_client_to_desktop;6;
KEY ShftAlt;8;follow_client_to_desktop;7;
KEY ShftAlt;9;follow_client_to_desktop;8;
KEY ShftAlt;0;follow_client_to_desktop;9;
-
+#
# Send an app to another desktop but dont't follow it
KEY ShftSuper;1;client_to_desktop;0;
KEY ShftSuper;2;client_to_desktop;1;
@@ -41,7 +41,7 @@ KEY ShftSuper;7;client_to_desktop;6;
KEY ShftSuper;8;client_to_desktop;7;
KEY ShftSuper;9;client_to_desktop;8;
KEY ShftSuper;0;client_to_desktop;9;
-
+#
KEY Alt;a;rotate_mode;1;
KEY Alt;c;kill_client;
KEY Alt;j;next_win;
@@ -52,14 +52,14 @@ KEY Alt;p;resize_stack;10;
KEY Alt;o;resize_stack;-10;
KEY Alt;u;update_config;
KEY Alt;Tab;last_desktop;
-
+#
# Shortcut for dmenu_run
KEY Alt;v;spawn;dmenucmd;
-
+#
# Add/remove a window to/from the master area in vertical/horizontal mode
KEY ShftAlt;m;more_master;1;
KEY ShftAlt;l;more_master;-1;
-
+#
# move windows
KEY ShftAlt;k;move_down;10;
KEY ShftAlt;j;move_up;-10;
@@ -76,12 +76,13 @@ KEY ShftAlt;h;switch_mode;2;
KEY ShftAlt;g;switch_mode;3;
# Switch tiling mode to center stacking
KEY ShftAlt;c;switch_mode;4;
-
+#
# Show/hide the bar
KEY Super;b;toggle_bar;
-
+#
# Shortcut for xterm
KEY Super;t;spawn;xtermcmd;
-
+#
# Shortcut to exit the window manager
KEY CtrlAlt;q;quit;
+#
View
7 sample.rc.conf
@@ -1,7 +1,7 @@
# lines starting with a hash are ignored
# Number of DESKTOPS should be first
DESKTOPS 6
-
+#
# switchertheme colours are :
# focused desktop in switcher
# unfocused desktop in switcher
@@ -19,7 +19,7 @@ STATUSTHEME #002030;#000000;#ffffff;#999999;#777755;#339933;#aa6644;#ffffff;#ddd
# windowtheme colours are :
# focused window border and unfocused window border
WINDOWTHEME #443311;#002030;
-
+#
BORDERWIDTH 2
# percentage of the desktop for the main window
MASTERSIZE 52
@@ -30,6 +30,8 @@ TOPSTACK 1
# default tiling modes for each desktop(defaults to 0):
# 0=vert,1=fullscreen,2=horiz,3=grid,4=stacking
DEFAULTMODE 3;4;0;1;2;3;
+# Select monitor the bar will be on, not needed with on monitor
+# BAR_MONITOR 1
# For semi transparent unfocused windows if using a compositor e.g. compton
UF_WIN_ALPHA 65
# only one of FOLLOWMOUSE and CLICKTOFOCUS should be zero, but none have to be
@@ -47,3 +49,4 @@ SHOWNUMOPEN 1
MODENAME [V];[F];[H];[G];[C];
DESKTOP_NAMES one;two;three;four;five;six;
FONTNAME "-*-clean-*-*-*-*-14-*-*-*-*-*-*-*"
+#
View
16 snapwm.c
@@ -195,7 +195,7 @@ static unsigned int attachaside, bdw, bool_quit, clicktofocus, current_desktop,
static unsigned int screen, followmouse, mode, msize, previous_desktop, DESKTOPS, STATUS_BAR;
static int num_screens, growth, sh, sw, master_size, nmaster;
static unsigned int sb_desks; // width of the desktop switcher
-static unsigned int sb_height, sb_width, screen, show_bar, has_bar, wnamebg;
+static unsigned int sb_height, sb_width, screen, show_bar, has_bar, wnamebg, barmon;
static unsigned int showopen; // whether the desktop switcher shows number of open windows
static unsigned int topbar, top_stack, windownamelength, keycount, cmdcount, dtcount, pcount, LA_WINDOWNAME;
static int ufalpha;
@@ -1289,18 +1289,18 @@ void init_desks() {
for (i = 0; i < num_screens; i++) {
for(j=i;j<DESKTOPS;j+=num_screens) {
- if(desktops[j].w > 0) continue;
- //printf("**screen is %d - desktop is %d **\n", i, j);
- desktops[j].x = info[i].x_org + last_width;
- desktops[j].y = info[i].y_org;
- desktops[j].w = info[i].width - bdw;
- if(i == 0 && STATUS_BAR == 0 && show_bar == 0) {
+ if(i == barmon && STATUS_BAR == 0 && show_bar == 0) {
desktops[j].h = info[i].height - (sb_height+4+bdw);
desktops[j].showbar = show_bar;
} else {
desktops[j].h = info[i].height - bdw;
desktops[j].showbar = 1;
}
+ if(desktops[j].w > 0) continue;
+ //printf("**screen is %d - desktop is %d **\n", i, j);
+ desktops[j].x = info[i].x_org + last_width;
+ desktops[j].y = info[i].y_org;
+ desktops[j].w = info[i].width - bdw;
//printf(" x=%d - y=%d - w=%d - h=%d \n", desktops[j].x, desktops[j].y, desktops[j].w, desktops[j].h);
desktops[j].master_size = (mode == 2) ? (desktops[j].h*msize)/100 : (desktops[j].w*msize)/100;
desktops[j].nmaster = 0;
@@ -1336,7 +1336,7 @@ void setup() {
showopen = clicktofocus = attachaside = 1;
resizemovekey = Mod1Mask;
windownamelength = 35;
- show_bar = STATUS_BAR = 0;
+ show_bar = STATUS_BAR = barmon = 0;
char *loc;
loc = setlocale(LC_ALL, "");

0 comments on commit 46f1956

Please sign in to comment.