Add support for setting shadow x and y offsets independently
Closes #3 Updated readme and gitignore
This commit is contained in:
parent
4077824698
commit
c6a0ec832a
21
.gitignore
vendored
21
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
|||
# ---> Autotools
|
||||
# http://www.gnu.org/software/automake
|
||||
|
||||
Makefile.in
|
||||
/ar-lib
|
||||
/mdate-sh
|
||||
/py-compile
|
||||
|
@ -14,15 +15,26 @@
|
|||
autom4te.cache
|
||||
/autoscan.log
|
||||
/autoscan-*.log
|
||||
/aclocal.m4
|
||||
/compile
|
||||
/config.cache
|
||||
/config.guess
|
||||
/config.h.in
|
||||
/config.log
|
||||
/config.status
|
||||
/config.sub
|
||||
/configure
|
||||
/configure~
|
||||
/configure.ac~
|
||||
/configure.scan
|
||||
/depcomp
|
||||
/install-sh
|
||||
/missing
|
||||
/stamp-h1
|
||||
|
||||
# https://www.gnu.org/software/libtool/
|
||||
|
||||
/ltmain.sh
|
||||
/libtool*
|
||||
|
||||
# http://www.gnu.org/software/texinfo
|
||||
|
@ -31,8 +43,14 @@ autom4te.cache
|
|||
|
||||
# http://www.gnu.org/software/m4/
|
||||
|
||||
m4/libtool.m4
|
||||
m4/ltoptions.m4
|
||||
m4/ltsugar.m4
|
||||
m4/ltversion.m4
|
||||
m4/lt~obsolete.m4
|
||||
|
||||
# Generated Makefile
|
||||
# (meta build systems like autotools,
|
||||
# (meta build system like autotools,
|
||||
# can automatically generate from config.status script
|
||||
# (which is called by configure script))
|
||||
Makefile
|
||||
|
@ -97,6 +115,7 @@ obj/
|
|||
# Project settings
|
||||
*.depend
|
||||
*.layout
|
||||
*.cscope_file_list
|
||||
|
||||
# ---> xosd-xft
|
||||
*osd-demo*
|
||||
|
|
16
README.md
16
README.md
|
@ -4,7 +4,7 @@ Inspired by [libxosd](https://sourceforge.net/projects/libxosd/).
|
|||
|
||||
`xosd-xft` supports:
|
||||
|
||||
* Use Xft/TTF fonts
|
||||
* Use of Xft/TTF fonts
|
||||
* Xrandr and Xinerama extensions
|
||||
* Allows you to choose a monitor in multihead setups - including active monitor
|
||||
* Use `osd-echo` to display a [Nerd Font](https://nerdfonts.com) glyph
|
||||
|
@ -12,12 +12,20 @@ Inspired by [libxosd](https://sourceforge.net/projects/libxosd/).
|
|||
|
||||
# Installation
|
||||
|
||||
## Manual installation
|
||||
```bash
|
||||
./autobuild.sh
|
||||
./configure
|
||||
make
|
||||
make -j$(nproc)
|
||||
sudo make install
|
||||
```
|
||||
|
||||
## Arch
|
||||
From the directory containing the PKGBUILD:
|
||||
```bash
|
||||
makepkg --syncdeps --install
|
||||
```
|
||||
|
||||
# Quick Look
|
||||
|
||||
## Using osd-echo
|
||||
|
@ -34,7 +42,7 @@ To list available glyph names that contain `volume` in them:
|
|||
osd-echo -lvolume
|
||||
```
|
||||
|
||||
## Using osd-showfile
|
||||
## Using osd-cat
|
||||
|
||||
To override the font used to display a file:
|
||||
```bash
|
||||
|
@ -70,7 +78,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
osd_set_geometry(osd, &g);
|
||||
osd_set_font(osd, "mono:size=16");
|
||||
osd_set_color(osd, "lightblue");
|
||||
osd_set_color(osd, "lightblue", 100);
|
||||
osd_set_bgcolor(osd, "black", 100);
|
||||
|
||||
char* message = "HELLO XOSD-XFT" ;
|
||||
|
|
|
@ -24,6 +24,7 @@ pkgver() {
|
|||
|
||||
build() {
|
||||
cd "${srcdir}/${_pkgname}"
|
||||
./autobuild.sh
|
||||
./configure --prefix=/usr
|
||||
make -j$(nproc)
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@ dnl Configure.ac for xosd_xft
|
|||
dnl
|
||||
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT([libxosd-xft],[1.1.0])
|
||||
AC_INIT(libxosd-xft, m4_esyscmd_s([git describe --abbrev=0 --tags]))
|
||||
AM_INIT_AUTOMAKE([no-define])
|
||||
|
||||
dnl
|
||||
dnl Require autoconf version 2.57
|
||||
dnl
|
||||
AC_PREREQ([2.71])
|
||||
AC_PREREQ(2.57)
|
||||
|
||||
dnl The libtool version numbers (LT_*); Don't even think about faking this!
|
||||
dnl
|
||||
|
|
|
@ -142,6 +142,8 @@
|
|||
<Add directory="/usr/lib/glib-2.0" />
|
||||
<Add directory="/usr/lib/glib-2.0/include" />
|
||||
<Add directory="/usr/include/sysprof-6" />
|
||||
<Add directory="/usr/x86_64-w64-mingw32/include" />
|
||||
<Add directory="/usr/i686-w64-mingw32/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="X11" />
|
||||
|
|
|
@ -93,7 +93,8 @@ typedef struct _osd_settings
|
|||
unsigned int bg_alpha;
|
||||
const char* shadow_color;
|
||||
unsigned int shadow_alpha;
|
||||
int shadow_offset;
|
||||
int shadow_offset_x;
|
||||
int shadow_offset_y;
|
||||
const char* padding;
|
||||
const char* text_align;
|
||||
} osd_settings;
|
||||
|
|
|
@ -45,7 +45,8 @@ void load_defaults(osd_settings *settings)
|
|||
settings->bg_alpha = 100;
|
||||
settings->shadow_color = "lightgrey";
|
||||
settings->shadow_alpha = 100;
|
||||
settings->shadow_offset = 0;
|
||||
settings->shadow_offset_x = 0;
|
||||
settings->shadow_offset_y = 0;
|
||||
settings->padding = "0";
|
||||
settings->text_align = "center";
|
||||
settings->maxlines = 1;
|
||||
|
@ -92,7 +93,7 @@ stay_on_top(Display *dpy, Window win)
|
|||
net_wm = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||
|
||||
/*
|
||||
* gnome-compilant
|
||||
* gnome-compliant
|
||||
* tested with icewm + WindowMaker
|
||||
*/
|
||||
if (Success == XGetWindowProperty(dpy, root, gnome, 0, (65536 / sizeof(long)), False,
|
||||
|
@ -400,8 +401,8 @@ event_loop(void *osdv)
|
|||
} else {
|
||||
y = osd->line_height * i + osd->w_pad_t + extents.y ;
|
||||
}
|
||||
if(osd->settings.shadow_offset) {
|
||||
XftDrawStringUtf8(osd->draw, &osd->shadow_color, osd->font, x + osd->settings.shadow_offset, y + osd->settings.shadow_offset, (const FcChar8 *)message, strlen(message));
|
||||
if(osd->settings.shadow_offset_x && osd->settings.shadow_offset_y) {
|
||||
XftDrawStringUtf8(osd->draw, &osd->shadow_color, osd->font, x + osd->settings.shadow_offset_x, y + osd->settings.shadow_offset_y, (const FcChar8 *)message, strlen(message));
|
||||
}
|
||||
XftDrawStringUtf8(osd->draw, &osd->text_color, osd->font, x, y, (const FcChar8 *)message, strlen(message));
|
||||
}
|
||||
|
@ -780,10 +781,11 @@ void osd_set_bgcolor(xosd_xft *osd, const char *bgcolor, unsigned int bgalpha)
|
|||
/* }}} */
|
||||
|
||||
/* osd_set_shadowoffset -- set offset for the shadow (0 - None) {{{ */
|
||||
void osd_set_shadowoffset(xosd_xft *osd, int offset)
|
||||
void osd_set_shadowoffset(xosd_xft *osd, int offset_x, int offset_y)
|
||||
{
|
||||
FUNCTION_START();
|
||||
osd->settings.shadow_offset = offset;
|
||||
osd->settings.shadow_offset_x = offset_x;
|
||||
osd->settings.shadow_offset_y = offset_y;
|
||||
FUNCTION_END();
|
||||
}
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ static struct option long_options[] = {
|
|||
{"monitor", 1, NULL, 'm'},
|
||||
#endif
|
||||
{"shadow-color", 1, NULL, 's'},
|
||||
{"shadow-alpha", 1, NULL, 'z'},
|
||||
{"shadow-offset", 1, NULL, 'S'},
|
||||
{"shadow-alpha", 1, NULL, 'S'},
|
||||
{"shadow-offset", 1, NULL, 'o'},
|
||||
{"padding", 1, NULL, 'p'},
|
||||
{"text-align", 1, NULL, 't'},
|
||||
|
||||
|
@ -79,20 +79,34 @@ static struct option long_options[] = {
|
|||
#endif
|
||||
{NULL, 0, NULL, 0}};
|
||||
|
||||
enum
|
||||
{
|
||||
OFFSET_X,
|
||||
OFFSET_Y
|
||||
};
|
||||
|
||||
const char *offset[] =
|
||||
{
|
||||
[OFFSET_X] = "x",
|
||||
[OFFSET_Y] = "y",
|
||||
NULL
|
||||
};
|
||||
|
||||
xosd_xft *osd;
|
||||
|
||||
/* Default Values */
|
||||
char* font = "SauceCodePro Nerd Font:size=64:antialias=true";
|
||||
char* text_color = "ghostwhite";
|
||||
int text_alpha = 50;
|
||||
char* bg_color = "black";
|
||||
int bg_alpha = 50;
|
||||
char* shadow_color = "lightgrey";
|
||||
char* font = "SauceCodePro Nerd Font:size=64:antialias=true";
|
||||
char* text_color = "ghostwhite";
|
||||
int text_alpha = 50;
|
||||
char* bg_color = "black";
|
||||
int bg_alpha = 50;
|
||||
char* shadow_color = "darkblue";
|
||||
int shadow_alpha = 50;
|
||||
int shadow_offset = 0;
|
||||
char* padding = "0";
|
||||
int delay_millis = 1000;
|
||||
char* command = NULL;
|
||||
int shadow_offset_x = 0;
|
||||
int shadow_offset_y = 0;
|
||||
char* padding = "0";
|
||||
int delay_millis = 1000;
|
||||
char* command = NULL;
|
||||
|
||||
#if defined(HAVE_LIBXINERAMA) || defined(HAVE_LIBXRANDR)
|
||||
int monitor = -1;
|
||||
|
@ -147,6 +161,7 @@ int main(int argc, char *argv[])
|
|||
while (1)
|
||||
{
|
||||
int option_index = 0;
|
||||
char *subopts, *value;
|
||||
int c =
|
||||
getopt_long(argc, argv, "D:f:c:e:l::m:g:p:b:a:d:ht:s:S:",
|
||||
long_options,
|
||||
|
@ -178,11 +193,37 @@ int main(int argc, char *argv[])
|
|||
case 's':
|
||||
shadow_color = optarg;
|
||||
break;
|
||||
case 'z':
|
||||
case 'S':
|
||||
shadow_alpha = atoi(optarg);
|
||||
break;
|
||||
case 'S':
|
||||
shadow_offset = atoi(optarg);
|
||||
case 'o':
|
||||
subopts = optarg;
|
||||
while(*subopts != NULL)
|
||||
{
|
||||
char *saved = subopts;
|
||||
switch(getsubopt(&subopts, (char **)offset, &value))
|
||||
{
|
||||
case OFFSET_X:
|
||||
if(value == NULL)
|
||||
{
|
||||
printf("Invalid x offset: '%d'\n", shadow_offset_x);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
shadow_offset_x = atoi(value);
|
||||
break;
|
||||
case OFFSET_Y:
|
||||
if(value == NULL)
|
||||
{
|
||||
printf("Invalid y offset: '%d'\n", shadow_offset_y);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
shadow_offset_y = atoi(value);
|
||||
break;
|
||||
default:
|
||||
printf("Unknown suboption: '%s'\n", saved);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
delay_millis = atoi(optarg);
|
||||
|
@ -255,7 +296,7 @@ int main(int argc, char *argv[])
|
|||
osd_set_textcolor(osd, text_color, text_alpha);
|
||||
osd_set_bgcolor(osd, bg_color, bg_alpha);
|
||||
osd_set_shadowcolor(osd, shadow_color, shadow_alpha);
|
||||
osd_set_shadowoffset(osd, shadow_offset);
|
||||
osd_set_shadowoffset(osd, shadow_offset_x, shadow_offset_y);
|
||||
osd_set_xinerama(osd, use_xinerama);
|
||||
osd_set_xrandr(osd, use_xrandr);
|
||||
|
||||
|
@ -307,9 +348,9 @@ help(char **argv)
|
|||
" -a, --bg-alpha=n Background transparency (default: %d)\n"
|
||||
" <n> should between 0-100\n"
|
||||
" -s, --shadow-color=color Shadow color (default: %s)\n"
|
||||
" -z, --shadow-alpha=n Shadow transparency (default: %d)\n"
|
||||
" -S, --shadow-alpha=n Shadow transparency (default: %d)\n"
|
||||
" <n> should between 0-100\n"
|
||||
" -S, --shadow-offset=n Shadow offset from text in pixels (default: %d)\n"
|
||||
" --shadow-offset x=n,y=m Shadow offset from text in pixels (default: %d,%d)\n"
|
||||
" -d, --delay-in-millis=n Delay in milliseconds (default: %d)\n"
|
||||
#ifdef HAVE_LIBXINERAMA
|
||||
" --no-xinerama Turn off xinerama support\n"
|
||||
|
@ -331,7 +372,7 @@ help(char **argv)
|
|||
" -D, --debug=<level> The debug levels to be enabled\n"
|
||||
" <level>: CSV of none function,locking,select,trace,value,update,all\n"
|
||||
#endif
|
||||
"\n\n", geometry, text_align, font, text_color, text_alpha, padding, bg_color, bg_alpha, shadow_color, shadow_alpha, shadow_offset, delay_millis );
|
||||
"\n\n", geometry, text_align, font, text_color, text_alpha, padding, bg_color, bg_alpha, shadow_color, shadow_alpha, shadow_offset_x, shadow_offset_y, delay_millis );
|
||||
}
|
||||
|
||||
/* vim: foldmethod=marker tabstop=2 shiftwidth=2 expandtab
|
||||
|
|
|
@ -178,7 +178,7 @@ void osd_set_shadowcolor(xosd_xft *osd, const char *shadowcolor, unsigned int sh
|
|||
* offset The offset for the shadow (0 - none)
|
||||
*
|
||||
*/
|
||||
void osd_set_shadowoffset(xosd_xft *osd, int offset);
|
||||
void osd_set_shadowoffset(xosd_xft *osd, int shadow_offset_x, int shadow_offset_y);
|
||||
|
||||
/* osd_set_xinerama -- Enable/disable xinerama
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue