DWL launching with systemd and setup changes
This commit is contained in:
parent
d2386bca8d
commit
b794ef8737
42
dwl.entourage
Executable file
42
dwl.entourage
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo "Entourage: $XDG_RUNTIME_DIR - $DWLTAGS_FILE" >> $XDG_RUNTIME_DIR/dwl.log
|
||||||
|
|
||||||
|
# Let DWL start
|
||||||
|
while [ ! -e "$XDG_RUNTIME_DIR/wayland-0.lock" ]
|
||||||
|
do
|
||||||
|
echo "DWL getting ready..." >> $XDG_RUNTIME_DIR/dwl.log
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo "DWL ready!" >> $XDG_RUNTIME_DIR/dwl.log
|
||||||
|
echo "Entourage: " $DWLTAGS_FILE >> $XDG_RUNTIME_DIR/dwl.log
|
||||||
|
|
||||||
|
# Top bar for displaying DWL tags
|
||||||
|
# TODO: Dependency - needs inotify-tools package
|
||||||
|
touch $DWLTAGS_FILE
|
||||||
|
inotifywait -q -m -e close_write $DWLTAGS_FILE |
|
||||||
|
(cat $DWLTAGS_FILE ;
|
||||||
|
while read -r filename event; do
|
||||||
|
cat $DWLTAGS_FILE
|
||||||
|
done) | dtao -z -z -ta l -h 22 -fn 'Iosevka Term:style=Regular:size=12' &
|
||||||
|
|
||||||
|
ps all >> $XDG_RUNTIME_DIR/dwl.log
|
||||||
|
export INOTIFYPID=$(ps all | grep inotifywait | grep -v grep | tail -1 | awk '{print $3}')
|
||||||
|
echo "inotifywait: " $INOTIFYPID >> $XDG_RUNTIME_DIR/dwl.log
|
||||||
|
|
||||||
|
# Bottom bar for displaying context information
|
||||||
|
(conky -c ~/.conkyrc) | dtao -b -z -z -ta r -h 20 -fn 'Iosevka Term:style=Regular:size=12' &
|
||||||
|
|
||||||
|
export CONKYPID=$!
|
||||||
|
echo "conky: " $CONKYPID >> $XDG_RUNTIME_DIR/dwl.log
|
||||||
|
|
||||||
|
# Background
|
||||||
|
swaybg --mode fill --image ~/.config/wallpaper.jpg &
|
||||||
|
|
||||||
|
echo "swaybg: " $! >> $XDG_RUNTIME_DIR/dwl.log
|
||||||
|
|
||||||
|
# Redirect STDIN to STDOUT and pass along to tags script
|
||||||
|
(while read line
|
||||||
|
do
|
||||||
|
echo $line
|
||||||
|
done) | dwltags.pl --file $DWLTAGS_FILE
|
29
dwl.service
Normal file
29
dwl.service
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# Systemd service to start DWL
|
||||||
|
# --
|
||||||
|
#
|
||||||
|
# Put this file in following directory:
|
||||||
|
#
|
||||||
|
# ~/.config/systemd/user
|
||||||
|
#
|
||||||
|
# Start this service with something like this:
|
||||||
|
#
|
||||||
|
# #!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# # Start DWL
|
||||||
|
#
|
||||||
|
# systemctl --user import-environment && \
|
||||||
|
# systemctl --wait --user start dwl.service
|
||||||
|
#
|
||||||
|
[Unit]
|
||||||
|
Description=DWL service
|
||||||
|
BindsTo=graphical-session.target
|
||||||
|
Wants=graphical-session-pre.target
|
||||||
|
After=graphical-session-pre.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
EnvironmentFile=-%h/.config/dwl/env
|
||||||
|
ExecStart=/home/mahesh/bin/dwl.session
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=1
|
||||||
|
TimeoutStopSec=10
|
35
dwl.session
35
dwl.session
@ -1,37 +1,16 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
export XDG_RUNTIME_DIR=$(mktemp --directory --suffix=.${USER})
|
||||||
|
|
||||||
|
echo $XDG_RUNTIME_DIR used for Wayland session
|
||||||
export WLR_LIBINPUT_NO_DEVICES=1
|
export WLR_LIBINPUT_NO_DEVICES=1
|
||||||
export PATH=~/bin:$PATH
|
export PATH=~/bin:$PATH
|
||||||
|
|
||||||
export DWLTAGS_FILE=/tmp/dwl.tags.$USER.out
|
export DWLTAGS_FILE=${XDG_RUNTIME_DIR}/dwl.tags.${USER}.out
|
||||||
# export DWLTAGS_FMT=TXT # Waybar uses this
|
# export DWLTAGS_FMT=TXT # Waybar uses this
|
||||||
export DWLTAGS_FMT=DZEN
|
export DWLTAGS_FMT=DZEN
|
||||||
|
|
||||||
# Clean up
|
echo "Session: in $1 " $DWLTAGS_FILE
|
||||||
ps aux | grep $USER | grep wl_show_bars | awk '{ print $2 }' | xargs -n 1 kill -9
|
echo "Session: " $DWLTAGS_FILE >> $XDG_RUNTIME_DIR/dwl.log
|
||||||
ps aux | grep $USER | grep dtao | awk '{ print $2 }' | xargs -n 1 kill -9
|
|
||||||
rm $DWLTAGS_FILE
|
|
||||||
|
|
||||||
(/usr/local/bin/dwl | dwltags.pl) &
|
exec /usr/local/bin/dwl -s $HOME/bin/dwl.entourage
|
||||||
|
|
||||||
# Let DWL start
|
|
||||||
while [ ! -e "$XDG_RUNTIME_DIR/wayland-0.lock" ]
|
|
||||||
do
|
|
||||||
echo "DWL getting ready..."
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
echo "DWL ready!"
|
|
||||||
|
|
||||||
# Top bar for displaying DWL tags
|
|
||||||
# TODO: Dependency - needs inotify-tools package
|
|
||||||
inotifywait -q -m -e close_write $DWLTAGS_FILE |
|
|
||||||
(cat $DWLTAGS_FILE ;
|
|
||||||
while read -r filename event; do
|
|
||||||
cat $DWLTAGS_FILE
|
|
||||||
done) | dtao -z -z -ta l -h 22 -fn 'Iosevka Term:style=Regular:size=12' &
|
|
||||||
|
|
||||||
# Bottom bar for displaying context information
|
|
||||||
(conky -c ~/.conkyrc) | dtao -b -z -z -ta r -h 20 -fn 'Iosevka Term:style=Regular:size=12' &
|
|
||||||
|
|
||||||
# Background
|
|
||||||
swaybg --mode fill --image ~/.config/wallpaper.jpg &
|
|
||||||
|
31
dwltags.pl
31
dwltags.pl
@ -5,8 +5,14 @@ use warnings;
|
|||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use Term::ANSIColor;
|
use Term::ANSIColor;
|
||||||
use FileHandle;
|
use FileHandle;
|
||||||
|
use Getopt::Long;
|
||||||
|
|
||||||
my $info = {};
|
my $info = {};
|
||||||
|
my $tags_file = $ENV{'DWLTAGS_FILE'};
|
||||||
|
my $log_file = $ENV{'XDG_RUNTIME_DIR'} . "/dwl.log";
|
||||||
|
|
||||||
|
GetOptions("file=s" => \$tags_file)
|
||||||
|
or die("Command line usage error");
|
||||||
|
|
||||||
# Color scheme is only used in ANSI mode
|
# Color scheme is only used in ANSI mode
|
||||||
# <class>_f/_g: class is used in JSON mode to be used in style.css for styling
|
# <class>_f/_g: class is used in JSON mode to be used in style.css for styling
|
||||||
@ -33,34 +39,38 @@ my $colorscheme = {
|
|||||||
# 'title_b' => 'black'
|
# 'title_b' => 'black'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
print_log("DWLTAGS: $tags_file");
|
||||||
|
|
||||||
print_tags({
|
print_tags({
|
||||||
'selmon' => '1',
|
'selmon' => '1',
|
||||||
'tags' => '1 1',
|
'tags' => '1 1',
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'layout' => '[]='
|
'layout' => '[]='
|
||||||
});
|
}, $tags_file);
|
||||||
|
|
||||||
while (<>) {
|
while (<>) {
|
||||||
my $line = $_;
|
my $line = $_;
|
||||||
chomp $line;
|
chomp $line;
|
||||||
|
|
||||||
|
# print_log("DWLTAGS [VV] : $line");
|
||||||
|
|
||||||
if (my ($mon, $key, $val) = $line =~ /^(\S+)\s+(\S+)\s(.*)$/) {
|
if (my ($mon, $key, $val) = $line =~ /^(\S+)\s+(\S+)\s(.*)$/) {
|
||||||
$info->{$key} = $val;
|
$info->{$key} = $val;
|
||||||
if ($key eq "layout") {
|
if ($key eq "layout") {
|
||||||
# Commit a status
|
# Commit a status
|
||||||
# Assumption: layout is the last piece of information dumped by DWL
|
# Assumption: layout is the last piece of information dumped by DWL
|
||||||
$info->{'mon'} = $mon;
|
$info->{'mon'} = $mon;
|
||||||
print_tags($info);
|
print_tags($info, $tags_file);
|
||||||
|
|
||||||
$info = {};
|
$info = {};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print "DWL: Printed out of format\n";
|
print_log("DWL: Printed out of format - $line");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub print_tags {
|
sub print_tags {
|
||||||
my ($info) = @_;
|
my ($info, $tags_file) = @_;
|
||||||
my $numtags = 10;
|
my $numtags = 10;
|
||||||
|
|
||||||
return if ($info->{'selmon'} ne "1");
|
return if ($info->{'selmon'} ne "1");
|
||||||
@ -85,13 +95,13 @@ sub print_tags {
|
|||||||
$tags .= getformatted("lay", " $info->{'layout'} ");
|
$tags .= getformatted("lay", " $info->{'layout'} ");
|
||||||
$tags .= getformatted("title", " $info->{'title'} ");
|
$tags .= getformatted("title", " $info->{'title'} ");
|
||||||
|
|
||||||
my $fh = FileHandle->new("> " . $ENV{'DWLTAGS_FILE'});
|
my $fh = FileHandle->new("> " . $tags_file);
|
||||||
if (defined $fh) {
|
if (defined $fh) {
|
||||||
print $fh $tags . "\n";
|
print $fh $tags . "\n";
|
||||||
$fh->close;
|
$fh->close;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print "DWL: Printed out of format - tags\n";
|
print_log("DWL: Printed out of format - tags");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,3 +130,12 @@ sub dzen_colored {
|
|||||||
# return colored([$colorscheme->{$c . '_f'} . " on_" . $colorscheme->{$c . '_b'}], $txt);
|
# return colored([$colorscheme->{$c . '_f'} . " on_" . $colorscheme->{$c . '_b'}], $txt);
|
||||||
return "^fg(" . $fc . ")^bg(" . $bc . ")" . $txt . "^fg()^bg()";
|
return "^fg(" . $fc . ")^bg(" . $bc . ")" . $txt . "^fg()^bg()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub print_log {
|
||||||
|
my ($line) = @_;
|
||||||
|
my $fh = FileHandle->new(">> " . $ENV{'XDG_RUNTIME_DIR'} . "/dwl.log");
|
||||||
|
if (defined $fh) {
|
||||||
|
print $fh $line . "\n";
|
||||||
|
$fh->close;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user