You are not logged in.
Pages: 1
Does anyone know a way of specifying a geometry for urxvt in pixels? As opposed to characters.
Or alternatively, a way to easily convert between the two? I'm trying to implement something like how echinus allows you to "draw" terminals. Only I think echinus takes advantage of the fact that it's a window manager to do this. Whereas I have an X, Y, Width and Height to work with.
Offline
~/.Xdefaults
URxvt.geometry: 70x35
And some other changes i did
URxvt.saveLines: 10000
URxvt.scrollBar: false
URxvt.foreground: white
URxvt.background: black
URxvt.secondaryScroll: true
URxvt.font: xft:liberation mono:pixelsize=11
i hope that is what you are looking for...
edit...
i've just read that you search for "PIXELS"
sorry
Last edited by nonickknown (2009-05-21 10:04:31)
Offline
It seems that (X)characters = 8x(X) pixels and (Y) characters = 16x(Y) pixels, a urxvt -geometry 160x25 would take 1280 px width and 400 px height
Offline
It depends on your font, of course. If you have a 9x16 font, you'll need to multiply your character number and the font width/height.
Offline
Ah ok I thought I might have to do this, thank you all for your input
Offline
It depends on your font, of course. If you have a 9x16 font, you'll need to multiply your character number and the font width/height.
Just realized this ...:/
Offline
I got it
To use it you can make a script like this (launchterm.sh), replace the width and height with whatever you need for your font:
let WIDTH=$3/5
let HEIGHT=$4/10
urxvtc -g ${WIDTH}x${HEIGHT}+${1}+${2} -e screen -x -R -p = &
And then compile this little app, which allows you to run different scripts when different mouse buttons are clicked on the root window:
/*
* Run stuff on root window clicks
* By HashBox
*/
#define RESOURCE_NAME "rootgrab"
#define MOUSE_BUTTONS 5
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
Display *dpy;
XEvent ev;
XrmDatabase db;
XrmValue button[5];
char xdb_path[128];
char *type;
int x, y, i;
if (!(dpy = XOpenDisplay(NULL))) {
fprintf(stderr, "Could not open display %s", getenv("DISPLAY"));
}
sprintf(xdb_path, "%s/.Xdefaults", getenv("HOME"));
XrmInitialize();
db = XrmGetFileDatabase(xdb_path);
for (i = 1; i <= MOUSE_BUTTONS; i++) {
char temp[24];
sprintf(temp, RESOURCE_NAME".button%i", i);
/* If a launch path is found for this button then grab this button so we get events for it */
if (XrmGetResource(db, temp, temp, &type, &button[i-1])) {
XGrabButton(dpy, i, 0, DefaultRootWindow(dpy), True, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
}
}
for (;;) {
XNextEvent(dpy, &ev);
if (ev.type == ButtonPress) {
if (ev.xbutton.subwindow == None) { /* Root Window */
/* Grab pointer so we receive ButtonRelease */
XGrabPointer(dpy, DefaultRootWindow(dpy), True, ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
x = ev.xbutton.x_root;
y = ev.xbutton.y_root;
}
XAllowEvents(dpy, ReplayPointer, CurrentTime); /* Allow other apps to process this message */
} else if (ev.type == ButtonRelease) {
XUngrabPointer(dpy, CurrentTime);
char shell_buff[256];
/* If last character of launch path is '%' then tack some variables on */
if (button[ev.xbutton.button-1].addr[strlen(button[ev.xbutton.button-1].addr)-1] == '%') {
int start_x, start_y, width, height;
width = ev.xbutton.x_root - x;
height = ev.xbutton.y_root - y;
/* Ugliness to make width/height positive and put the start positions
* in the right place so we can draw backwards basically. */
if (width < 0) { width = abs(width); start_x = ev.xbutton.x_root; } else { start_x = x; }
if (height < 0) { height = abs(height); start_y = ev.xbutton.y_root; } else { start_y = y; }
sprintf(shell_buff, "%.*s %i %i %i %i &", strlen(button[ev.xbutton.button-1].addr)-1, button[ev.xbutton.button-1].addr, start_x, start_y, width, height);
} else {
sprintf(shell_buff, "%s &", button[ev.xbutton.button-1].addr);
}
system(shell_buff);
}
}
XCloseDisplay(dpy);
return 0;
}
And then place something like this in your .Xdefaults (Draw terminals with left button, display menu on right click, and scroll up/down to change volume):
rootgrab*button1: launchterm.sh%
rootgrab*button3: rootmenu.sh%
rootgrab*button4: amixer -q sset Master 1+
rootgrab*button5: amixer -q sset Master 1-
The "%" at the end of the first two scripts indicates that the app should pass $X $Y $WIDTH $HEIGHT as parameters when launched.
EDIT: Updated the code a bit
Last edited by HashBox (2009-05-23 04:51:47)
Offline
Pages: 1