spawn function
This commit is contained in:
parent
e17f9fd459
commit
06f344c8fb
4 changed files with 16 additions and 5 deletions
|
@ -135,7 +135,6 @@ void Bar::render()
|
|||
renderText(layoutNames[_layout]);
|
||||
_titleX = _x;
|
||||
renderText(_title);
|
||||
_statusX = _x;
|
||||
renderStatus();
|
||||
|
||||
_painter = nullptr;
|
||||
|
@ -184,8 +183,8 @@ void Bar::renderStatus()
|
|||
{
|
||||
_painter->fillRect(_x, 0, _bufs->width-_x, _bufs->height, _painter->brush());
|
||||
auto size = textWidth(_status) + paddingX;
|
||||
_x = _bufs->width - size;
|
||||
_painter->drawText(paddingX+_x, _textY, _status);
|
||||
_statusX = _bufs->width - size;
|
||||
_painter->drawText(paddingX+_statusX, _textY, _status);
|
||||
_x = _bufs->width;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,7 @@ struct ColorScheme {
|
|||
QColor fg, bg;
|
||||
};
|
||||
union Arg {
|
||||
int i;
|
||||
unsigned int ui;
|
||||
float f;
|
||||
const void *v;
|
||||
};
|
||||
struct Monitor;
|
||||
|
@ -42,6 +40,7 @@ void toggleview(Monitor &m, const Arg &arg);
|
|||
void setlayout(Monitor &m, const Arg &arg);
|
||||
void tag(Monitor &m, const Arg &arg);
|
||||
void toggletag(Monitor &m, const Arg &arg);
|
||||
void spawn(Monitor&, const Arg &arg);
|
||||
|
||||
// wayland smart pointers
|
||||
template<typename T>
|
||||
|
|
|
@ -15,6 +15,7 @@ constexpr bool fontBold = false;
|
|||
|
||||
constexpr ColorScheme colorInactive = {QColor(0xbb, 0xbb, 0xbb), QColor(0x22, 0x22, 0x22)};
|
||||
constexpr ColorScheme colorActive = {QColor(0xee, 0xee, 0xee), QColor(0x00, 0x55, 0x77)};
|
||||
constexpr const char *termcmd[] = {"foot", nullptr};
|
||||
|
||||
constexpr Button buttons[] = {
|
||||
{ ClkTagBar, BTN_LEFT, toggleview, {0} },
|
||||
|
@ -23,4 +24,5 @@ constexpr Button buttons[] = {
|
|||
{ ClkTagBar, BTN_MIDDLE, toggletag, {0} },
|
||||
{ ClkLayoutSymbol, BTN_LEFT, setlayout, {.ui = 0} },
|
||||
{ ClkLayoutSymbol, BTN_RIGHT, setlayout, {.ui = 2} },
|
||||
{ ClkWinTitle, BTN_RIGHT, spawn, {.v = termcmd} },
|
||||
};
|
||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -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);
|
||||
}
|
||||
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 = {
|
||||
[](void*, xdg_wm_base *sender, uint32_t serial) {
|
||||
|
|
Loading…
Reference in a new issue