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