Added autostart patch
This commit is contained in:
parent
7cfabce39a
commit
288e314761
|
@ -29,6 +29,36 @@ const char *modes_labels[] = {
|
|||
"quick_launch",
|
||||
};
|
||||
|
||||
/* Autostart */
|
||||
#define AS_SHCMD(cmd) "sh", "-c", cmd, NULL
|
||||
static const char *const autostart[] = {
|
||||
AS_SHCMD("./builddir/subprojects/dwl-bar/dwl-bar"),
|
||||
AS_SHCMD("pipewire"),
|
||||
AS_SHCMD("pipewire-pulse"),
|
||||
AS_SHCMD("wireplumber"),
|
||||
AS_SHCMD("xdg-desktop-portal-wlr"),
|
||||
AS_SHCMD("swaync"),
|
||||
AS_SHCMD("status.pl"),
|
||||
AS_SHCMD("nm-applet"),
|
||||
AS_SHCMD("swaybg -o DP-1 -i \"/home/charadon/Pictures/wp1926016.jpg\""),
|
||||
AS_SHCMD("swaybg -o HDMI-A-2 -i \"/home/charadon/Pictures/1583944.jpg\""),
|
||||
AS_SHCMD("guake"),
|
||||
AS_SHCMD("keepassxc"),
|
||||
AS_SHCMD("akregator"),
|
||||
AS_SHCMD("gtk-launch element-desktop"),
|
||||
AS_SHCMD("gtk-launch signal-desktop"),
|
||||
AS_SHCMD("gtk-launch mullvad-vpn"),
|
||||
AS_SHCMD("thunderbird"),
|
||||
AS_SHCMD("firefox"),
|
||||
AS_SHCMD("pragha"),
|
||||
AS_SHCMD("ua.org.brezblock.q4wine"),
|
||||
AS_SHCMD("org.flameshot.Flameshot"),
|
||||
AS_SHCMD("gammastep"),
|
||||
AS_SHCMD("swayidle -w before-sleep swaylock"),
|
||||
NULL /* end of list */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||
#define TAGCOUNT (9)
|
||||
|
@ -49,6 +79,7 @@ static const Rule rules[] = {
|
|||
{ "thunderbird-default", NULL, 1 << 1, 0, 0, 0, 0, 1},
|
||||
{ "flameshot", NULL, ~0, 1, 1, 0, 1, -1},
|
||||
{ "guake", NULL, ~0, 0, 1, 0, 0, -1},
|
||||
{ "net.iotib.Shortcuts", NULL, ~0, 0, 1, 0, 0, -1},
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
|
@ -134,22 +165,23 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
|
|||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
#define APP_LAUNCHER "wofi -l top -D drun-display_generic=true -H 200 -W 1920 -G -o DP-1 -m -I -S drun"
|
||||
#define APP_LAUNCHER "wofi -l top -D drun-print_command=true -D drun-display_generic=true -H 200 -W 1920 -G -o DP-1 -m -I -S drun"
|
||||
|
||||
|
||||
/* commands */
|
||||
static const Key keys[] = {
|
||||
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XKB_KEY_r, spawn, SHCMD(APP_LAUNCHER) },
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XKB_KEY_r, spawn, SHCMD(APP_LAUNCHER) },
|
||||
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pamixer --allow-boost -i 10 && ogg123 /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga")},
|
||||
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pamixer --allow-boost -d 10 && ogg123 /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga")},
|
||||
{ 0, XKB_KEY_Print, spawn, SHCMD("org.flameshot.Flameshot gui --raw | wl-copy") },
|
||||
{ WLR_MODIFIER_SHIFT, XKB_KEY_Print, spawn, SHCMD("hyprpicker | tr -d '\n' | wl-copy")},
|
||||
{ 0, XKB_KEY_XF86AudioPlay, spawn, SHCMD("playerctl-toggle.pl") },
|
||||
{ 0, XKB_KEY_XF86AudioNext, spawn, SHCMD("playerctl -p pragha next") },
|
||||
{ 0, XKB_KEY_XF86AudioPrev, spawn, SHCMD("playerctl -p pragha previous") },
|
||||
{ 0, XKB_KEY_XF86AudioStop, spawn, SHCMD("playerctl -p pragha stop") },
|
||||
{ 0, XKB_KEY_Print, spawn, SHCMD("org.flameshot.Flameshot gui --raw | wl-copy") },
|
||||
{ WLR_MODIFIER_SHIFT, XKB_KEY_Print, spawn, SHCMD("hyprpicker | tr -d '\n' | wl-copy")},
|
||||
{ 0, XKB_KEY_XF86AudioPlay, spawn, SHCMD("playerctl-toggle.pl") },
|
||||
{ 0, XKB_KEY_XF86AudioNext, spawn, SHCMD("playerctl -p pragha next") },
|
||||
{ 0, XKB_KEY_XF86AudioPrev, spawn, SHCMD("playerctl -p pragha previous") },
|
||||
{ 0, XKB_KEY_XF86AudioStop, spawn, SHCMD("playerctl -p pragha stop") },
|
||||
{ MODKEY, XKB_KEY_slash, spawn, SHCMD("net.iotib.Shortcuts") },
|
||||
/* Auto Type */
|
||||
{ WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT, XKB_KEY_P, spawn, SHCMD("wl-paste | wtype -d 20 -")},
|
||||
/* Key modes */
|
||||
|
|
|
@ -42,10 +42,11 @@ swayidle_sub = subproject(
|
|||
'logind-provider=elogind',
|
||||
]
|
||||
)
|
||||
dwlmsg_sub = subproject('dwlmsg')
|
||||
pamixer_sub = subproject('pamixer')
|
||||
swaybg_sub = subproject('swaybg')
|
||||
portal_sub = subproject('xdg-desktop-portal-wlr')
|
||||
dwlmsg_sub = subproject('dwlmsg')
|
||||
pamixer_sub = subproject('pamixer')
|
||||
swaybg_sub = subproject('swaybg')
|
||||
portal_sub = subproject('xdg-desktop-portal-wlr')
|
||||
shortcuts_sub = subproject('shortcuts')
|
||||
|
||||
# Hyprpicker
|
||||
meson.add_postconf_script('scripts/build-hyprpicker.pl')
|
||||
|
|
|
@ -16,18 +16,18 @@ sub run_cmd {
|
|||
return(1);
|
||||
}
|
||||
|
||||
my $MESON_BUILD_ROOT = $ENV{MESON_BUILD_ROOT} // die("Couldn't get environment variable: MESON_BUILD_ROOT");
|
||||
my $MESON_SOURCE_ROOT = $ENV{MESON_SOURCE_ROOT} // die("Couldn't get environment variable: MESON_SOURCE_ROOT");
|
||||
use constant MESON_BUILD_ROOT => scalar $ENV{MESON_BUILD_ROOT} // die("Couldn't get environment variable: MESON_BUILD_ROOT");
|
||||
use constant MESON_SOURCE_ROOT => scalar $ENV{MESON_SOURCE_ROOT} // die("Couldn't get environment variable: MESON_SOURCE_ROOT");
|
||||
|
||||
# Copy hyprpicker subproject to build root.
|
||||
# We use the system `cp` command because there's no recursive copy function in the
|
||||
# perl core modules. It's not that big of a deal anyways.
|
||||
if(!run_cmd("cp -r $MESON_SOURCE_ROOT/subprojects/hyprpicker $MESON_BUILD_ROOT/")) {
|
||||
if(!run_cmd("cp -r ".MESON_SOURCE_ROOT."/subprojects/hyprpicker ".MESON_BUILD_ROOT."/")) {
|
||||
die("Failed to copy hyprpicker subproject.");
|
||||
}
|
||||
|
||||
# Build Hyprpicker
|
||||
chdir("$MESON_BUILD_ROOT/hyprpicker") or die($ERRNO);
|
||||
chdir(MESON_BUILD_ROOT."/hyprpicker") or die($ERRNO);
|
||||
if(!run_cmd("make")) {
|
||||
# Try gmake
|
||||
if(!run_cmd("gmake")) {
|
||||
|
@ -36,6 +36,6 @@ if(!run_cmd("make")) {
|
|||
}
|
||||
|
||||
# Copy the finished build into subprojects folder.
|
||||
make_path("$MESON_BUILD_ROOT/subprojects/hyprpicker") or die($ERRNO);
|
||||
cp("build/hyprpicker", "$MESON_BUILD_ROOT/subprojects/hyprpicker/hyprpicker") or die($ERRNO);
|
||||
make_path(MESON_BUILD_ROOT."/subprojects/hyprpicker") or die($ERRNO);
|
||||
cp("build/hyprpicker", MESON_BUILD_ROOT."/subprojects/hyprpicker/hyprpicker") or die($ERRNO);
|
||||
exit(0);
|
||||
|
|
14
session.pl
14
session.pl
|
@ -3,7 +3,7 @@ use strict;
|
|||
use warnings FATAL => qw(uninitialized);
|
||||
use English;
|
||||
use Cwd qw(abs_path);
|
||||
use File::Basename qw(dirname);
|
||||
use File::Basename qw(dirname basename);
|
||||
use File::Path qw(remove_tree make_path);
|
||||
# Set up environment.
|
||||
$ENV{XDG_CURRENT_DESKTOP} = "sway";
|
||||
|
@ -53,6 +53,10 @@ sub link_sub_binary {
|
|||
my $project = $ARG[0];
|
||||
symlink("${subPath}/${project}/${project}", "${binPath}/${project}");
|
||||
}
|
||||
sub link_built_binary {
|
||||
my $exe = $ARG[0];
|
||||
symlink("${subPath}/$exe", "${binPath}/". basename($exe));
|
||||
}
|
||||
sub link_script {
|
||||
my $file = $ARG[0];
|
||||
symlink("${scriptDir}/runtime-scripts/${file}", "${binPath}/${file}");
|
||||
|
@ -66,6 +70,7 @@ link_sub_binary("wev");
|
|||
link_sub_binary("pamixer");
|
||||
link_sub_binary("hyprpicker");
|
||||
link_sub_binary("xdg-desktop-portal-wlr");
|
||||
link_built_binary("shortcuts/net.iotib.Shortcuts");
|
||||
link_script("playerctl-toggle.pl");
|
||||
link_script("status.pl");
|
||||
# Create empty current_mode file.
|
||||
|
@ -78,9 +83,4 @@ $ENV{PATH} = "${XDG_RUNTIME_DIR}/cdwl/bin:" . $ENV{PATH};
|
|||
|
||||
|
||||
# Run window manager.
|
||||
system("meson setup builddir && ninja -C builddir && dbus-run-session ssh-agent builddir/dwl -s \"./run.sh\" 2>err.log");
|
||||
# Kill some problematic processes that won't die.
|
||||
`pkill pipewire`;
|
||||
`pkill pipewire-pulse`;
|
||||
`pgrep -a perl | grep status.pl | awk '{print \$1}' | xargs kill`;
|
||||
`killall -9 dwl-bar`;
|
||||
system("meson setup builddir && ninja -C builddir && dbus-run-session ssh-agent builddir/dwl 2>err.log");
|
||||
|
|
60
src/dwl.c
60
src/dwl.c
|
@ -270,6 +270,7 @@ typedef struct {
|
|||
|
||||
/* function declarations */
|
||||
static void applybounds(Client *c, struct wlr_box *bbox);
|
||||
static void autostartexec(void);
|
||||
static void applyrules(Client *c);
|
||||
static void arrange(Monitor *m);
|
||||
static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
|
@ -482,6 +483,8 @@ static xcb_atom_t netatom[NetLast];
|
|||
|
||||
/* attempt to encapsulate suck into one file */
|
||||
#include "client.h"
|
||||
static pid_t *autostart_pids;
|
||||
static size_t autostart_len;
|
||||
|
||||
struct Pertag {
|
||||
unsigned int curtag, prevtag; /* current and previous tag */
|
||||
|
@ -510,6 +513,28 @@ applybounds(Client *c, struct wlr_box *bbox)
|
|||
c->geom.y = bbox->y;
|
||||
}
|
||||
|
||||
void
|
||||
autostartexec(void) {
|
||||
const char *const *p;
|
||||
size_t i = 0;
|
||||
|
||||
/* count entries */
|
||||
for (p = autostart; *p; autostart_len++, p++)
|
||||
while (*++p);
|
||||
|
||||
autostart_pids = calloc(autostart_len, sizeof(pid_t));
|
||||
for (p = autostart; *p; i++, p++) {
|
||||
if ((autostart_pids[i] = fork()) == 0) {
|
||||
setsid();
|
||||
execvp(*p, (char *const *)p);
|
||||
die("dwl: execvp %s:", *p);
|
||||
}
|
||||
/* skip arguments */
|
||||
while (*++p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
applyrules(Client *c)
|
||||
{
|
||||
|
@ -768,11 +793,21 @@ checkidleinhibitor(struct wlr_surface *exclude)
|
|||
void
|
||||
cleanup(void)
|
||||
{
|
||||
size_t i;
|
||||
#ifdef XWAYLAND
|
||||
wlr_xwayland_destroy(xwayland);
|
||||
xwayland = NULL;
|
||||
#endif
|
||||
wl_display_destroy_clients(dpy);
|
||||
|
||||
/* kill child processes */
|
||||
for (i = 0; i < autostart_len; i++) {
|
||||
if (0 < autostart_pids[i]) {
|
||||
kill(autostart_pids[i], SIGTERM);
|
||||
waitpid(autostart_pids[i], NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (child_pid > 0) {
|
||||
kill(child_pid, SIGTERM);
|
||||
waitpid(child_pid, NULL, 0);
|
||||
|
@ -1812,18 +1847,32 @@ void
|
|||
handlesig(int signo)
|
||||
{
|
||||
if (signo == SIGCHLD) {
|
||||
#ifdef XWAYLAND
|
||||
|
||||
siginfo_t in;
|
||||
/* wlroots expects to reap the XWayland process itself, so we
|
||||
* use WNOWAIT to keep the child waitable until we know it's not
|
||||
* XWayland.
|
||||
*/
|
||||
while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid
|
||||
&& (!xwayland || in.si_pid != xwayland->server->pid))
|
||||
waitpid(in.si_pid, NULL, 0);
|
||||
#else
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
#ifdef XWAYLAND
|
||||
&& (!xwayland || in.si_pid != xwayland->server->pid)
|
||||
#endif
|
||||
) {
|
||||
pid_t *p, *lim;
|
||||
waitpid(in.si_pid, NULL, 0);
|
||||
if (in.si_pid == child_pid)
|
||||
child_pid = -1;
|
||||
if (!(p = autostart_pids))
|
||||
continue;
|
||||
lim = &p[autostart_len];
|
||||
|
||||
for (; p < lim; p++) {
|
||||
if (*p == in.si_pid) {
|
||||
*p = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (signo == SIGINT || signo == SIGTERM) {
|
||||
quit(NULL);
|
||||
}
|
||||
|
@ -2558,6 +2607,7 @@ run(char *startup_cmd)
|
|||
die("startup: backend_start");
|
||||
|
||||
/* Now that the socket exists and the backend is started, run the startup command */
|
||||
autostartexec();
|
||||
if (startup_cmd) {
|
||||
int piperw[2];
|
||||
if (pipe(piperw) < 0)
|
||||
|
|
Loading…
Reference in New Issue