spawn function

This commit is contained in:
Raphael Robatsch 2021-10-26 16:40:19 +02:00
parent e17f9fd459
commit 06f344c8fb
4 changed files with 16 additions and 5 deletions

View File

@ -135,7 +135,6 @@ void Bar::render()
renderText(layoutNames[_layout]); renderText(layoutNames[_layout]);
_titleX = _x; _titleX = _x;
renderText(_title); renderText(_title);
_statusX = _x;
renderStatus(); renderStatus();
_painter = nullptr; _painter = nullptr;
@ -184,8 +183,8 @@ void Bar::renderStatus()
{ {
_painter->fillRect(_x, 0, _bufs->width-_x, _bufs->height, _painter->brush()); _painter->fillRect(_x, 0, _bufs->width-_x, _bufs->height, _painter->brush());
auto size = textWidth(_status) + paddingX; auto size = textWidth(_status) + paddingX;
_x = _bufs->width - size; _statusX = _bufs->width - size;
_painter->drawText(paddingX+_x, _textY, _status); _painter->drawText(paddingX+_statusX, _textY, _status);
_x = _bufs->width; _x = _bufs->width;
} }

View File

@ -15,9 +15,7 @@ struct ColorScheme {
QColor fg, bg; QColor fg, bg;
}; };
union Arg { union Arg {
int i;
unsigned int ui; unsigned int ui;
float f;
const void *v; const void *v;
}; };
struct Monitor; struct Monitor;
@ -42,6 +40,7 @@ void toggleview(Monitor &m, const Arg &arg);
void setlayout(Monitor &m, const Arg &arg); void setlayout(Monitor &m, const Arg &arg);
void tag(Monitor &m, const Arg &arg); void tag(Monitor &m, const Arg &arg);
void toggletag(Monitor &m, const Arg &arg); void toggletag(Monitor &m, const Arg &arg);
void spawn(Monitor&, const Arg &arg);
// wayland smart pointers // wayland smart pointers
template<typename T> template<typename T>

View File

@ -15,6 +15,7 @@ constexpr bool fontBold = false;
constexpr ColorScheme colorInactive = {QColor(0xbb, 0xbb, 0xbb), QColor(0x22, 0x22, 0x22)}; constexpr ColorScheme colorInactive = {QColor(0xbb, 0xbb, 0xbb), QColor(0x22, 0x22, 0x22)};
constexpr ColorScheme colorActive = {QColor(0xee, 0xee, 0xee), QColor(0x00, 0x55, 0x77)}; constexpr ColorScheme colorActive = {QColor(0xee, 0xee, 0xee), QColor(0x00, 0x55, 0x77)};
constexpr const char *termcmd[] = {"foot", nullptr};
constexpr Button buttons[] = { constexpr Button buttons[] = {
{ ClkTagBar, BTN_LEFT, toggleview, {0} }, { ClkTagBar, BTN_LEFT, toggleview, {0} },
@ -23,4 +24,5 @@ constexpr Button buttons[] = {
{ ClkTagBar, BTN_MIDDLE, toggletag, {0} }, { ClkTagBar, BTN_MIDDLE, toggletag, {0} },
{ ClkLayoutSymbol, BTN_LEFT, setlayout, {.ui = 0} }, { ClkLayoutSymbol, BTN_LEFT, setlayout, {.ui = 0} },
{ ClkLayoutSymbol, BTN_RIGHT, setlayout, {.ui = 2} }, { ClkLayoutSymbol, BTN_RIGHT, setlayout, {.ui = 2} },
{ ClkWinTitle, BTN_RIGHT, spawn, {.v = termcmd} },
}; };

View File

@ -90,6 +90,17 @@ void toggletag(Monitor &m, const Arg &arg)
{ {
znet_tapesoftware_dwl_wm_monitor_v1_set_client_tags(m.dwlMonitor.get(), 0xffffff, arg.ui); znet_tapesoftware_dwl_wm_monitor_v1_set_client_tags(m.dwlMonitor.get(), 0xffffff, arg.ui);
} }
void spawn(Monitor&, const Arg &arg)
{
if (fork()) {
auto argv = static_cast<char* const*>(arg.v);
setsid();
execvp(argv[0], argv);
fprintf(stderr, "somebar: execvp %s ", argv[0]);
perror(" failed");
exit(1);
}
}
static const struct xdg_wm_base_listener xdgWmBaseListener = { static const struct xdg_wm_base_listener xdgWmBaseListener = {
[](void*, xdg_wm_base *sender, uint32_t serial) { [](void*, xdg_wm_base *sender, uint32_t serial) {