Skip to content

Commit

Permalink
Changed DEFAULT_MODE line in rc.conf to set each desktop mode
Browse files Browse the repository at this point in the history
  • Loading branch information
moetunes committed Oct 11, 2012
1 parent 1407148 commit 8be9dd9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 48 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,7 @@
11/10/12
Changed the DEFAULT_MODE line in rc.conf
to set the default mode for each desktop

10/10/12 10/10/12
Added multi monitor support Added multi monitor support


Expand Down
18 changes: 0 additions & 18 deletions config.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,26 +6,8 @@
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H


#define STATUS_BAR 0 /* 1=Don't 0=Make the bar */
#define FONTS_ERROR 1 /* 1=Don't 0=Print errors about missing fonts */ #define FONTS_ERROR 1 /* 1=Don't 0=Print errors about missing fonts */


// The settings from here to defaultfont[] are in the rc file, which has precedence,
// so if the rc file all has these 15 options they don't have to be changed.

#define UF_ALPHA 75 /* Percentage transparency for unfocused windows - 100 to turn off */
#define MASTER_SIZE 55
#define BORDER_WIDTH 2
#define RESIZEMOVEKEY MOD1
#define ATTACH_ASIDE 1 /* 1=Don't 0=Place new window in the stack */
#define TOP_STACK 0 /* 1=Don't 0=Place new window at the top of the stack when using ATTACH_ASIDE*/
#define DEFAULT_MODE 4 /* 0=Vertical, 1=Fullscreen 2=Horizontal 3=Grid 4=Stacking*/
#define FOLLOW_MOUSE 0 /* 1=Don't 0=Focus the window the mouse just entered */
#define CLICK_TO_FOCUS 1 /* 1=Don't 0=Focus an unfocused window when clicked */
#define TOP_BAR 0 /* 1=Don't 0=Have the bar at the top instead of the bottom */
#define SHOW_BAR 0 /* 1=Don't 0=Have the bar shown at startup */
#define SHOW_NUM_OPEN 1 /* 1=Dont' 0=Show the number of open windows in the switcher */
#define WINDOW_NAME_LENGTH 35 /* Character length for the current window's name in the bar */

static const char *defaultdesktopnames[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", }; 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 *defaultbarcolor[] = { "#ff0000", "#00ff00", "#0000ff", "#000000", };
static const char *defaulttextcolor[] = { "#000000", "#ffffff", "#ffffff", "#ffff00", "#ff00ff", "#f0f0f0", "#0f0f0f", "#000000", "#000000", "#000000", }; static const char *defaulttextcolor[] = { "#000000", "#ffffff", "#ffffff", "#ffff00", "#ff00ff", "#f0f0f0", "#0f0f0f", "#000000", "#000000", "#000000", };
Expand Down
21 changes: 13 additions & 8 deletions readrc.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void read_rcfile() {
char buffer[256]; char buffer[256];
char dummy[256]; char dummy[256];
char *dummy2, *dummy3; char *dummy2, *dummy3;
unsigned int i; unsigned int i; int j=-1;


rcfile = fopen( RC_FILE, "rb" ) ; rcfile = fopen( RC_FILE, "rb" ) ;
if ( rcfile == NULL ) { if ( rcfile == NULL ) {
Expand Down Expand Up @@ -58,7 +58,15 @@ void read_rcfile() {
} else if(strstr(buffer, "CLICKTOFOCUS" ) != NULL) { } else if(strstr(buffer, "CLICKTOFOCUS" ) != NULL) {
clicktofocus = atoi(strstr(buffer, " ")+1); clicktofocus = atoi(strstr(buffer, " ")+1);
} else if(strstr(buffer, "DEFAULTMODE" ) != NULL) { } else if(strstr(buffer, "DEFAULTMODE" ) != NULL) {
mode = atoi(strstr(buffer, " ")+1); strncpy(dummy, strstr(buffer, " ")+1, strlen(strstr(buffer, " ")+1)-1);
dummy[strlen(dummy)-1] = '\0';
dummy2 = strdup(dummy);
for(i=0;i<DESKTOPS; ++i) {
j = atoi(strsep(&dummy2, ";"));
if(j > -1 && j < 5)
desktops[i].mode = j;
if(dummy2 == NULL) break;
}
} else if(STATUS_BAR == 0) { } else if(STATUS_BAR == 0) {
if(strstr(buffer, "SWITCHERTHEME" ) != NULL) { if(strstr(buffer, "SWITCHERTHEME" ) != NULL) {
strncpy(dummy, strstr(buffer, " ")+1, strlen(strstr(buffer, " ")+1)-1); strncpy(dummy, strstr(buffer, " ")+1, strlen(strstr(buffer, " ")+1)-1);
Expand Down Expand Up @@ -177,14 +185,14 @@ void set_defaults() {
if(STATUS_BAR == 0) { if(STATUS_BAR == 0) {
for(i=0;i<4;++i) for(i=0;i<4;++i)
theme[i].barcolor = getcolor(defaultbarcolor[i]); theme[i].barcolor = getcolor(defaultbarcolor[i]);
for(i=0;i<10;++i)
theme[i].textcolor = getcolor(defaulttextcolor[i]);
for(i=0;i<5;++i) for(i=0;i<5;++i)
theme[i].modename = strdup(defaultmodename[i]); theme[i].modename = strdup(defaultmodename[i]);
for(i=0;i<10;++i) { for(i=0;i<10;++i) {
if(!(defaultdesktopnames[i])) if(!(defaultdesktopnames[i]))
sb_bar[i].label = strdup("?"); sb_bar[i].label = strdup("?");
else sb_bar[i].label = strdup(defaultdesktopnames[i]); else sb_bar[i].label = strdup(defaultdesktopnames[i]);
theme[i].textcolor = getcolor(defaulttextcolor[i]);
desktops[i].mode = mode;
} }
strncpy(font_list, defaultfontlist, strlen(defaultfontlist)); strncpy(font_list, defaultfontlist, strlen(defaultfontlist));
get_font(); get_font();
Expand Down Expand Up @@ -244,11 +252,8 @@ void update_config() {
XFillRectangle(dis, area_sb, theme[0].gc, 0, 0, total_w, sb_height+4); XFillRectangle(dis, area_sb, theme[0].gc, 0, 0, total_w, sb_height+4);
} }
} }
for(i=0;i<DESKTOPS;++i) { for(i=0;i<DESKTOPS;++i)
desktops[i].master_size = (desktops[i].mode == 2) ? (desktops[i].h*msize)/100 : (desktops[i].w*msize)/100; desktops[i].master_size = (desktops[i].mode == 2) ? (desktops[i].h*msize)/100 : (desktops[i].w*msize)/100;
if(desktops[i].head == NULL)
desktops[i].mode = mode;
}
select_desktop(current_desktop); select_desktop(current_desktop);
Arg a = {.i = mode}; switch_mode(a); Arg a = {.i = mode}; switch_mode(a);
tile(); tile();
Expand Down
5 changes: 3 additions & 2 deletions sample.rc.conf
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ MASTERSIZE 52
ATTACHASIDE 1 ATTACHASIDE 1
# if new window is in the stack add it at the top # if new window is in the stack add it at the top
TOPSTACK 1 TOPSTACK 1
# default tiling mode: 0=vert,1=fullscreen,2=horiz,3=grid,4=stacking # default tiling modes for each desktop(defaults to 0):
DEFAULTMODE 0 # 0=vert,1=fullscreen,2=horiz,3=grid,4=stacking
DEFAULTMODE 3;4;0;1;2;3;
# For semi transparent unfocused windows if using a compositor e.g. compton # For semi transparent unfocused windows if using a compositor e.g. compton
UF_WIN_ALPHA 65 UF_WIN_ALPHA 65
# only one of FOLLOWMOUSE and CLICKTOFOCUS should be zero, but none have to be # only one of FOLLOWMOUSE and CLICKTOFOCUS should be zero, but none have to be
Expand Down
34 changes: 14 additions & 20 deletions snapwm.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static unsigned int wc_size(char *string);
// Variable // Variable
static Display *dis; static Display *dis;
static unsigned int attachaside, bdw, bool_quit, clicktofocus, current_desktop, doresize, dowarp; static unsigned int attachaside, bdw, bool_quit, clicktofocus, current_desktop, doresize, dowarp;
static unsigned int screen, followmouse, mode, msize, previous_desktop, DESKTOPS; static unsigned int screen, followmouse, mode, msize, previous_desktop, DESKTOPS, STATUS_BAR;
static int num_screens, growth, sh, sw, master_size, nmaster; static int num_screens, growth, sh, sw, master_size, nmaster;
static unsigned int sb_desks; // width of the desktop switcher 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;
Expand Down Expand Up @@ -285,8 +285,8 @@ void add_window(Window w, int tw, client *cl) {
c->next = NULL; c->prev = NULL; c->next = NULL; c->prev = NULL;
dummy = c; dummy = c;
} else { } else {
if(ATTACH_ASIDE == 0) { if(attachaside == 0) {
if(TOP_STACK == 0) { if(top_stack == 0) {
c->next = dummy->next; c->prev = dummy; c->next = dummy->next; c->prev = dummy;
dummy->next = c; dummy->next = c;
} else { } else {
Expand Down Expand Up @@ -1293,7 +1293,7 @@ void init_desks() {
//printf("**screen is %d - desktop is %d **\n", i, j); //printf("**screen is %d - desktop is %d **\n", i, j);
desktops[j].x = info[i].x_org + last_width; desktops[j].x = info[i].x_org + last_width;
desktops[j].y = info[i].y_org; desktops[j].y = info[i].y_org;
desktops[j].w = info[i].width - BORDER_WIDTH; desktops[j].w = info[i].width - bdw;
if(i == 0 && STATUS_BAR == 0 && show_bar == 0) { if(i == 0 && STATUS_BAR == 0 && show_bar == 0) {
desktops[j].h = info[i].height - (sb_height+4+bdw); desktops[j].h = info[i].height - (sb_height+4+bdw);
desktops[j].showbar = show_bar; desktops[j].showbar = show_bar;
Expand All @@ -1304,7 +1304,7 @@ void init_desks() {
//printf(" x=%d - y=%d - w=%d - h=%d \n", desktops[j].x, desktops[j].y, desktops[j].w, desktops[j].h); //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].master_size = (mode == 2) ? (desktops[j].h*msize)/100 : (desktops[j].w*msize)/100;
desktops[j].nmaster = 0; desktops[j].nmaster = 0;
desktops[j].mode = mode; //desktops[j].mode = mode;
desktops[j].growth = 0; desktops[j].growth = 0;
desktops[j].numwins = 0; desktops[j].numwins = 0;
desktops[j].head = NULL; desktops[j].head = NULL;
Expand All @@ -1328,21 +1328,15 @@ void setup() {


// Initialize variables // Initialize variables
DESKTOPS = 4; DESKTOPS = 4;
mode = DEFAULT_MODE; topbar = followmouse = top_stack = mode = 0;
msize = MASTER_SIZE; LA_WINDOWNAME = wnamebg = dowarp = doresize = 0;
ufalpha = UF_ALPHA; msize = 55;
bdw = BORDER_WIDTH; ufalpha = 75;
attachaside = ATTACH_ASIDE; bdw = 2;
top_stack = TOP_STACK; showopen = clicktofocus = attachaside = 1;
followmouse = FOLLOW_MOUSE;
clicktofocus = CLICK_TO_FOCUS;
resizemovekey = Mod1Mask; resizemovekey = Mod1Mask;
windownamelength = WINDOW_NAME_LENGTH; windownamelength = 35;
topbar = TOP_BAR; show_bar = STATUS_BAR = 0;
showopen = SHOW_NUM_OPEN;
LA_WINDOWNAME = wnamebg = 0;
dowarp = doresize = 0;
show_bar = STATUS_BAR;


char *loc; char *loc;
loc = setlocale(LC_ALL, ""); loc = setlocale(LC_ALL, "");
Expand All @@ -1362,7 +1356,7 @@ void setup() {
setup_status_bar(); setup_status_bar();
status_bar(); status_bar();
update_output(1); update_output(1);
if(SHOW_BAR > 0) toggle_bar(); if(show_bar > 0) toggle_bar();
} }
read_apps_file(); read_apps_file();


Expand Down

0 comments on commit 8be9dd9

Please sign in to comment.