Skip to content

Commit

Permalink
made session text customizable: font, colors, position, prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
sip committed Sep 20, 2008
1 parent 567148b commit 72a0cc5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 11 deletions.
15 changes: 13 additions & 2 deletions THEMES
Expand Up @@ -31,6 +31,12 @@ OPTIONS
msg_x 50%
msg_y 30

# Color, font, position for the session list
session_color #FFFFFF
session_font Verdana:size=16:bold
session_x 50%
session_y 90%

# style of background: 'stretch', 'tile', 'center', 'color'
background_style stretch
background_color #FF0033
Expand Down Expand Up @@ -82,8 +88,8 @@ OPTIONS

SHADOWS

The 'msg', 'input', 'welcome' and 'username' sections support
shadows; three values can be configured:
The 'msg', 'input', 'welcome', 'session' and 'username' sections
support shadows; three values can be configured:
- color: the shadow color
- x offset: the offset in x direction, relative to the normal text
- y offset: the offset in y direction, relative to the normal text
Expand Down Expand Up @@ -112,6 +118,11 @@ SHADOWS
msg_shadow_xoffset 1
msg_shadow_yoffset 1
msg_shadow_color #ff00ff

# For the session:
session_shadow_xoffset 1
session_shadow_yoffset 1
session_shadow_color #ff00ff
----------------------------------------------------------------------


10 changes: 10 additions & 0 deletions cfg.cpp
Expand Up @@ -43,6 +43,7 @@ Cfg::Cfg()
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"""));
options.insert(option("screenshot_cmd","import -window root /slim.png"));
options.insert(option("welcome_msg","Welcome to %host"));
options.insert(option("session_msg","Session:"));
options.insert(option("default_user",""));
options.insert(option("focus_password","no"));
options.insert(option("auto_login","no"));
Expand Down Expand Up @@ -109,6 +110,15 @@ Cfg::Cfg()
options.insert(option("msg_shadow_xoffset", "0"));
options.insert(option("msg_shadow_yoffset", "0"));
options.insert(option("msg_shadow_color","#FFFFFF"));


options.insert(option("session_color","#FFFFFF"));
options.insert(option("session_font","Verdana:size=16:bold"));
options.insert(option("session_x","50%"));
options.insert(option("session_y","90%"));
options.insert(option("session_shadow_xoffset", "0"));
options.insert(option("session_shadow_yoffset", "0"));
options.insert(option("session_shadow_color","#FFFFFF"));

error = "";

Expand Down
30 changes: 21 additions & 9 deletions panel.cpp
Expand Up @@ -51,6 +51,10 @@ Panel::Panel(Display* dpy, int scr, Window root, Cfg* config,
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("msg_color").c_str(), &msgcolor);
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("msg_shadow_color").c_str(), &msgshadowcolor);
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("intro_color").c_str(), &introcolor);
XftColorAllocName(Dpy, DefaultVisual(Dpy, Scr), colormap,
cfg->getOption("session_color").c_str(), &sessioncolor);
XftColorAllocName(Dpy, DefaultVisual(Dpy, Scr), colormap,
cfg->getOption("session_shadow_color").c_str(), &sessionshadowcolor);

// Load properties from config / theme
input_name_x = Cfg::string2int(cfg->getOption("input_name_x").c_str());
Expand Down Expand Up @@ -139,6 +143,8 @@ Panel::~Panel() {
XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &msgcolor);
XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &welcomecolor);
XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &entercolor);
XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &sessioncolor);
XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &sessionshadowcolor);
XFreeGC(Dpy, TextGC);
XftFontClose(Dpy, font);
XftFontClose(Dpy, msgfont);
Expand Down Expand Up @@ -566,23 +572,29 @@ void Panel::SwitchSession() {

// Display session type on the screen
void Panel::ShowSession() {
string msg_x, msg_y;
XClearWindow(Dpy, Root);
string currsession = "Session: " + session;
string currsession = cfg->getOption("session_msg") + " " + session;
XGlyphInfo extents;
XftDraw *draw = XftDrawCreate(Dpy, Root,

sessionfont = XftFontOpenName(Dpy, Scr, cfg->getOption("session_font").c_str());

XftDraw *draw = XftDrawCreate(Dpy, Root,
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
XftTextExtents8(Dpy, msgfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
XftTextExtents8(Dpy, sessionfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
currsession.length(), &extents);
int msg_x = Cfg::absolutepos("50%", XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
int msg_y = XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)) - extents.height -100;
msg_x = cfg->getOption("session_x");
msg_y = cfg->getOption("session_y");
int x = Cfg::absolutepos(msg_x, XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
int y = Cfg::absolutepos(msg_y, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height);
int shadowXOffset =
Cfg::string2int(cfg->getOption("msg_shadow_xoffset").c_str());
Cfg::string2int(cfg->getOption("session_shadow_xoffset").c_str());
int shadowYOffset =
Cfg::string2int(cfg->getOption("msg_shadow_yoffset").c_str());
Cfg::string2int(cfg->getOption("session_shadow_yoffset").c_str());

SlimDrawString8(draw, &msgcolor, msgfont, msg_x, msg_y,
SlimDrawString8(draw, &sessioncolor, sessionfont, x, y,
currsession,
&msgshadowcolor,
&sessionshadowcolor,
shadowXOffset, shadowYOffset);
XFlush(Dpy);
XftDrawDestroy(draw);
Expand Down
5 changes: 5 additions & 0 deletions panel.h
Expand Up @@ -100,6 +100,9 @@ class Panel {
XftFont* introfont;
XftFont* welcomefont;
XftColor welcomecolor;
XftFont* sessionfont;
XftColor sessioncolor;
XftColor sessionshadowcolor;
XftColor welcomeshadowcolor;
XftFont* enterfont;
XftColor entercolor;
Expand All @@ -124,6 +127,8 @@ class Panel {
int welcome_y;
int welcome_shadow_xoffset;
int welcome_shadow_yoffset;
int session_shadow_xoffset;
int session_shadow_yoffset;
int intro_x;
int intro_y;
int username_x;
Expand Down
3 changes: 3 additions & 0 deletions slim.conf
Expand Up @@ -59,6 +59,9 @@ screenshot_cmd import -window root /slim.png
# welcome message. Available variables: %host, %domain
welcome_msg Welcome to %host

# Session message. Prepended to the session name when pressing F1
# session_msg Session:

# shutdown / reboot messages
shutdown_msg The system is halting...
reboot_msg The system is rebooting...
Expand Down

0 comments on commit 72a0cc5

Please sign in to comment.