Compare commits
3 Commits
fffbb5d5e0
...
0abcd17f22
Author | SHA1 | Date |
---|---|---|
John Mertz | 0abcd17f22 | |
John Mertz | c0cb1ed8a7 | |
John Mertz | 0cfe8d4079 |
|
@ -393,7 +393,7 @@ my $t = Proc::ProcessTable->new();
|
||||||
foreach my $p ( @{ $t->table } ) {
|
foreach my $p ( @{ $t->table } ) {
|
||||||
my $cmndline = $p->{'cmndline'};
|
my $cmndline = $p->{'cmndline'};
|
||||||
$cmndline =~ s/\s*$//g;
|
$cmndline =~ s/\s*$//g;
|
||||||
if ($cmndline =~ /^(waybar|wallpaper\.pl).*/) {
|
if ($cmndline =~ /^waybar.*/) {
|
||||||
# Never kill this process
|
# Never kill this process
|
||||||
if ($p->{'pid'} == $$) {
|
if ($p->{'pid'} == $$) {
|
||||||
next;
|
next;
|
||||||
|
@ -546,13 +546,5 @@ unless ($pid) {
|
||||||
`WAYLAND_DISPLAY=$waydisplay nohup $waybar_bin -b waybar0 --config=$waybar_config >> $ENV{'HOME'}/.waybar.log`;
|
`WAYLAND_DISPLAY=$waydisplay nohup $waybar_bin -b waybar0 --config=$waybar_config >> $ENV{'HOME'}/.waybar.log`;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Start wallpapers script as fork
|
# Restart wallpaper daemon
|
||||||
if ($w) {
|
`systemctl --user restart wallpapers.service`;
|
||||||
$pid = fork;
|
|
||||||
unless ($pid) {
|
|
||||||
open STDIN, '/dev/null';
|
|
||||||
open STDOUT, '>>/dev/null';
|
|
||||||
open STDERR, '>>/dev/null';
|
|
||||||
`/usr/bin/perl $ENV{'HOME'}/scripts/sway/wallpaper.pl -d $w`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
27
sway/idle.sh
27
sway/idle.sh
|
@ -8,6 +8,7 @@ HIBERNATE_TIMEOUT=3600 # one hour
|
||||||
|
|
||||||
BLFILE="$HOME/.local/state/idle.dim"
|
BLFILE="$HOME/.local/state/idle.dim"
|
||||||
OPFILE="$HOME/.local/state/active_outputs"
|
OPFILE="$HOME/.local/state/active_outputs"
|
||||||
|
STATEFILE="$HOME/.local/state/idle.state"
|
||||||
IDLEMODE=$(cat $HOME/.local/state/idle_mode)
|
IDLEMODE=$(cat $HOME/.local/state/idle_mode)
|
||||||
if [[ -n $2 ]]; then
|
if [[ -n $2 ]]; then
|
||||||
if [[ $2 == '--ignore_mode' ]]; then
|
if [[ $2 == '--ignore_mode' ]]; then
|
||||||
|
@ -89,14 +90,22 @@ elif [[ $1 == "start" ]]; then
|
||||||
resume "$0 unsleep" \
|
resume "$0 unsleep" \
|
||||||
timeout $HIBERNATE_TIMEOUT "$0 hibernate" \
|
timeout $HIBERNATE_TIMEOUT "$0 hibernate" \
|
||||||
resume "$0 unhibernate"
|
resume "$0 unhibernate"
|
||||||
|
if [[ -e $STATEFILE ]]; then
|
||||||
|
rm $STATEFILE
|
||||||
|
fi
|
||||||
elif [[ $1 == "daemon" ]]; then
|
elif [[ $1 == "daemon" ]]; then
|
||||||
nohup $0 start 2>/dev/null &
|
nohup $0 start 2>/dev/null &
|
||||||
elif [[ $1 == "stop" ]]; then
|
elif [[ $1 == "stop" ]]; then
|
||||||
pkill swayidle
|
pkill swayidle
|
||||||
|
if [[ -e $STATEFILE ]]; then
|
||||||
|
rm $STATEFILE
|
||||||
|
fi
|
||||||
elif [[ $1 == "fade" ]]; then
|
elif [[ $1 == "fade" ]]; then
|
||||||
if [[ $IDLEMODE -gt 0 ]]; then
|
if [[ $IDLEMODE -gt 0 ]]; then
|
||||||
|
echo 'hide' > $STATEFILE
|
||||||
if [[ ! -e $HOME/.local/state/sway-hidden ]]; then
|
if [[ ! -e $HOME/.local/state/sway-hidden ]]; then
|
||||||
kill -USR2 $(cat $HOME/.local/state/sway-transparency)
|
kill -USR2 $(cat $HOME/.local/state/sway-transparency)
|
||||||
|
makoctl mode -a hide
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [[ $1 == "unfade" ]]; then
|
elif [[ $1 == "unfade" ]]; then
|
||||||
|
@ -104,25 +113,37 @@ elif [[ $1 == "unfade" ]]; then
|
||||||
kill -USR2 $(cat $HOME/.local/state/sway-transparency)
|
kill -USR2 $(cat $HOME/.local/state/sway-transparency)
|
||||||
# TODO: This is a hack. There's no reason that waybar should be dead.
|
# TODO: This is a hack. There's no reason that waybar should be dead.
|
||||||
#$HOME/scripts/sway/displays.pl -w
|
#$HOME/scripts/sway/displays.pl -w
|
||||||
|
makoctl mode -r hide
|
||||||
|
fi
|
||||||
|
if [[ -e $STATEFILE ]]; then
|
||||||
|
rm $STATEFILE
|
||||||
fi
|
fi
|
||||||
elif [[ $1 == "dim" ]]; then
|
elif [[ $1 == "dim" ]]; then
|
||||||
if [[ $IDLEMODE -gt 1 ]]; then
|
if [[ $IDLEMODE -gt 1 ]]; then
|
||||||
|
echo 'dim' > $STATEFILE
|
||||||
# I don't currently have any dimable monitors, so fade was created instead
|
# I don't currently have any dimable monitors, so fade was created instead
|
||||||
makoctl set-mode away
|
|
||||||
echo $($HOME/scripts/thinkpad/blc.pl %) >$BLFILE
|
echo $($HOME/scripts/thinkpad/blc.pl %) >$BLFILE
|
||||||
$HOME/scripts/thinkpad/blc.pl = 1 &>-
|
$HOME/scripts/thinkpad/blc.pl = 1 &>-
|
||||||
fi
|
fi
|
||||||
elif [[ $1 == "undim" ]]; then
|
elif [[ $1 == "undim" ]]; then
|
||||||
makoctl set-mode default
|
makoctl set-mode default
|
||||||
$HOME/scripts/thinkpad/blc.pl = $(cat $BLFILE) &>-
|
$HOME/scripts/thinkpad/blc.pl = $(cat $BLFILE) &>-
|
||||||
|
if [[ -e $STATEFILE ]]; then
|
||||||
|
rm $STATEFILE
|
||||||
|
fi
|
||||||
elif [[ $1 == "lock" ]]; then
|
elif [[ $1 == "lock" ]]; then
|
||||||
if [[ $IDLEMODE -gt 2 ]]; then
|
if [[ $IDLEMODE -gt 2 ]]; then
|
||||||
|
echo 'lock' > $STATEFILE
|
||||||
swaylock -f -c 00000000
|
swaylock -f -c 00000000
|
||||||
fi
|
fi
|
||||||
elif [[ $1 == "unlock" ]]; then
|
elif [[ $1 == "unlock" ]]; then
|
||||||
kill -USR1 $(pgrep swaylock)
|
kill -USR1 $(pgrep swaylock)
|
||||||
|
if [[ -e $STATEFILE ]]; then
|
||||||
|
rm $STATEFILE
|
||||||
|
fi
|
||||||
elif [[ $1 == "sleep" ]]; then
|
elif [[ $1 == "sleep" ]]; then
|
||||||
if [[ $IDLEMODE -gt 3 ]]; then
|
if [[ $IDLEMODE -gt 3 ]]; then
|
||||||
|
echo 'sleep' > $STATEFILE
|
||||||
for i in $(cat $OPFILE); do swaymsg "output $i dpms off"; done
|
for i in $(cat $OPFILE); do swaymsg "output $i dpms off"; done
|
||||||
fi
|
fi
|
||||||
elif [[ $1 == "unsleep" ]]; then
|
elif [[ $1 == "unsleep" ]]; then
|
||||||
|
@ -131,8 +152,12 @@ elif [[ $1 == "unsleep" ]]; then
|
||||||
cd $HOME/scripts/sway
|
cd $HOME/scripts/sway
|
||||||
source $HOME/.dotfiles/bash/plenv-path.sh
|
source $HOME/.dotfiles/bash/plenv-path.sh
|
||||||
$HOME/scripts/sway/displays.pl 2>&1 >$HOME/.local/state/display_unsleep
|
$HOME/scripts/sway/displays.pl 2>&1 >$HOME/.local/state/display_unsleep
|
||||||
|
if [[ -e $STATEFILE ]]; then
|
||||||
|
rm $STATEFILE
|
||||||
|
fi
|
||||||
elif [[ $1 == "hibernate" ]]; then
|
elif [[ $1 == "hibernate" ]]; then
|
||||||
if [[ $IDLEMODE -gt 4 ]]; then
|
if [[ $IDLEMODE -gt 4 ]]; then
|
||||||
|
echo 'hibernate' > $STATEFILE
|
||||||
sudo systemctl suspend-then-hibernate.target
|
sudo systemctl suspend-then-hibernate.target
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ -e ${HOME}/.local/state/idle.state ]]; then
|
||||||
|
${HOME}/scripts/sway/idle.sh unfade
|
||||||
|
else
|
||||||
|
${HOME}/scripts/sway/idle.sh fade
|
||||||
|
fi
|
Loading…
Reference in New Issue