Skip to content

Commit 72a0cc5

Browse files
author
sip
committedSep 20, 2008
made session text customizable: font, colors, position, prefix
1 parent 567148b commit 72a0cc5

File tree

5 files changed

+52
-11
lines changed

5 files changed

+52
-11
lines changed
 

‎THEMES

+13-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ OPTIONS
3131
msg_x 50%
3232
msg_y 30
3333

34+
# Color, font, position for the session list
35+
session_color #FFFFFF
36+
session_font Verdana:size=16:bold
37+
session_x 50%
38+
session_y 90%
39+
3440
# style of background: 'stretch', 'tile', 'center', 'color'
3541
background_style stretch
3642
background_color #FF0033
@@ -82,8 +88,8 @@ OPTIONS
8288

8389
SHADOWS
8490

85-
The 'msg', 'input', 'welcome' and 'username' sections support
86-
shadows; three values can be configured:
91+
The 'msg', 'input', 'welcome', 'session' and 'username' sections
92+
support shadows; three values can be configured:
8793
- color: the shadow color
8894
- x offset: the offset in x direction, relative to the normal text
8995
- y offset: the offset in y direction, relative to the normal text
@@ -112,6 +118,11 @@ SHADOWS
112118
msg_shadow_xoffset 1
113119
msg_shadow_yoffset 1
114120
msg_shadow_color #ff00ff
121+
122+
# For the session:
123+
session_shadow_xoffset 1
124+
session_shadow_yoffset 1
125+
session_shadow_color #ff00ff
115126
----------------------------------------------------------------------
116127

117128

‎cfg.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Cfg::Cfg()
4343
options.insert(option("console_cmd","/usr/bin/xterm -C -fg white -bg black +sb -g %dx%d+%d+%d -fn %dx%d -T ""Console login"" -e /bin/sh -c ""/bin/cat /etc/issue; exec /bin/login"""));
4444
options.insert(option("screenshot_cmd","import -window root /slim.png"));
4545
options.insert(option("welcome_msg","Welcome to %host"));
46+
options.insert(option("session_msg","Session:"));
4647
options.insert(option("default_user",""));
4748
options.insert(option("focus_password","no"));
4849
options.insert(option("auto_login","no"));
@@ -109,6 +110,15 @@ Cfg::Cfg()
109110
options.insert(option("msg_shadow_xoffset", "0"));
110111
options.insert(option("msg_shadow_yoffset", "0"));
111112
options.insert(option("msg_shadow_color","#FFFFFF"));
113+
114+
115+
options.insert(option("session_color","#FFFFFF"));
116+
options.insert(option("session_font","Verdana:size=16:bold"));
117+
options.insert(option("session_x","50%"));
118+
options.insert(option("session_y","90%"));
119+
options.insert(option("session_shadow_xoffset", "0"));
120+
options.insert(option("session_shadow_yoffset", "0"));
121+
options.insert(option("session_shadow_color","#FFFFFF"));
112122

113123
error = "";
114124

‎panel.cpp

+21-9
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ Panel::Panel(Display* dpy, int scr, Window root, Cfg* config,
5151
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("msg_color").c_str(), &msgcolor);
5252
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("msg_shadow_color").c_str(), &msgshadowcolor);
5353
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("intro_color").c_str(), &introcolor);
54+
XftColorAllocName(Dpy, DefaultVisual(Dpy, Scr), colormap,
55+
cfg->getOption("session_color").c_str(), &sessioncolor);
56+
XftColorAllocName(Dpy, DefaultVisual(Dpy, Scr), colormap,
57+
cfg->getOption("session_shadow_color").c_str(), &sessionshadowcolor);
5458

5559
// Load properties from config / theme
5660
input_name_x = Cfg::string2int(cfg->getOption("input_name_x").c_str());
@@ -139,6 +143,8 @@ Panel::~Panel() {
139143
XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &msgcolor);
140144
XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &welcomecolor);
141145
XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &entercolor);
146+
XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &sessioncolor);
147+
XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &sessionshadowcolor);
142148
XFreeGC(Dpy, TextGC);
143149
XftFontClose(Dpy, font);
144150
XftFontClose(Dpy, msgfont);
@@ -566,23 +572,29 @@ void Panel::SwitchSession() {
566572

567573
// Display session type on the screen
568574
void Panel::ShowSession() {
575+
string msg_x, msg_y;
569576
XClearWindow(Dpy, Root);
570-
string currsession = "Session: " + session;
577+
string currsession = cfg->getOption("session_msg") + " " + session;
571578
XGlyphInfo extents;
572-
XftDraw *draw = XftDrawCreate(Dpy, Root,
579+
580+
sessionfont = XftFontOpenName(Dpy, Scr, cfg->getOption("session_font").c_str());
581+
582+
XftDraw *draw = XftDrawCreate(Dpy, Root,
573583
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
574-
XftTextExtents8(Dpy, msgfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
584+
XftTextExtents8(Dpy, sessionfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
575585
currsession.length(), &extents);
576-
int msg_x = Cfg::absolutepos("50%", XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
577-
int msg_y = XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)) - extents.height -100;
586+
msg_x = cfg->getOption("session_x");
587+
msg_y = cfg->getOption("session_y");
588+
int x = Cfg::absolutepos(msg_x, XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
589+
int y = Cfg::absolutepos(msg_y, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height);
578590
int shadowXOffset =
579-
Cfg::string2int(cfg->getOption("msg_shadow_xoffset").c_str());
591+
Cfg::string2int(cfg->getOption("session_shadow_xoffset").c_str());
580592
int shadowYOffset =
581-
Cfg::string2int(cfg->getOption("msg_shadow_yoffset").c_str());
593+
Cfg::string2int(cfg->getOption("session_shadow_yoffset").c_str());
582594

583-
SlimDrawString8(draw, &msgcolor, msgfont, msg_x, msg_y,
595+
SlimDrawString8(draw, &sessioncolor, sessionfont, x, y,
584596
currsession,
585-
&msgshadowcolor,
597+
&sessionshadowcolor,
586598
shadowXOffset, shadowYOffset);
587599
XFlush(Dpy);
588600
XftDrawDestroy(draw);

‎panel.h

+5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ class Panel {
100100
XftFont* introfont;
101101
XftFont* welcomefont;
102102
XftColor welcomecolor;
103+
XftFont* sessionfont;
104+
XftColor sessioncolor;
105+
XftColor sessionshadowcolor;
103106
XftColor welcomeshadowcolor;
104107
XftFont* enterfont;
105108
XftColor entercolor;
@@ -124,6 +127,8 @@ class Panel {
124127
int welcome_y;
125128
int welcome_shadow_xoffset;
126129
int welcome_shadow_yoffset;
130+
int session_shadow_xoffset;
131+
int session_shadow_yoffset;
127132
int intro_x;
128133
int intro_y;
129134
int username_x;

‎slim.conf

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ screenshot_cmd import -window root /slim.png
5959
# welcome message. Available variables: %host, %domain
6060
welcome_msg Welcome to %host
6161

62+
# Session message. Prepended to the session name when pressing F1
63+
# session_msg Session:
64+
6265
# shutdown / reboot messages
6366
shutdown_msg The system is halting...
6467
reboot_msg The system is rebooting...

0 commit comments

Comments
 (0)
Please sign in to comment.