This commit is contained in:
John Mertz 2023-01-07 08:16:47 -05:00
parent 6d33d9446f
commit 6cbadb5d5d
Signed by: jpm
GPG Key ID: E9C5EA2D867501AB
14 changed files with 461 additions and 263 deletions

View File

@ -53,6 +53,10 @@ elif [ $1 == "fade" ]; then
elif [ $1 == "unfade" ]; then
if [ -e $HOME/.spool/sway-hidden ]; then
kill -USR2 `cat $HOME/.spool/sway-transparency`
<<<<<<< Updated upstream
=======
/home/jpm/scripts/sway/displays.pl -w
>>>>>>> Stashed changes
fi
elif [ $1 == "dim" ]; then
echo $($HOME/scripts/thinkpad/blc.pl %) > $BLFILE

View File

@ -32,10 +32,17 @@ elif [ "$res" == "↹ Restart i3" ]; then
i3 restart
elif [ "$res" == "↻ Reload Sway" ]; then
sway reload
<<<<<<< Updated upstream
/home/jpm/scripts/sway/displays.pl
elif [ "$res" == "↻ Reload Waybar" ]; then
# Need to integrate with sway/displays.pl for alternative outputs
/home/jpm/scripts/sway/displays.pl -w
=======
/home/jpm/scripts/distrobox/debian12/displays.sh
elif [ "$res" == "↻ Reload Waybar" ]; then
# Need to integrate with sway/displays.pl for alternative outputs
/home/jpm/scripts/distrobox/debian12/displays.sh -w
>>>>>>> Stashed changes
elif [ "$res" == "🡙 Reboot" ]; then
rm $SSH_AUTH_SOCK
sudo systemctl reboot -i

View File

@ -20,7 +20,7 @@ export FLATPAK_IDE_LOG_LEVEL="0"
export "$( gnome-keyring-daemon --start )"
#WLR_RENDERER=vulkan sway --debug 2>> $HOME/.swaylog >> $HOME/.swaylog
WLR_RENDERER=gles2 sway --debug 2>> $HOME/.swaylog >> $HOME/.swaylog; export SWAYSOCK=`sway --get-socketpath`
WLR_RENDERER=gles2 sway --debug 2>> $HOME/.swaylog >> $HOME/.swaylog
#WLR_RENDERER=vulkan sway --debug 2>> $HOME/.swaylog >> $HOME/.swaylog
#WLR_RENDERER=gles2 $HOME/build/sway/build/sway/sway --debug 2>> $HOME/.swaylog >> $HOME/.swaylog
export SWAYSOCK=`sway --get-socketpath`

View File

@ -32,6 +32,7 @@ Sets a wallpaper by cropping an appropriate sized section of a larger image.\n
All arguments other than the below are assumed to be output names, as defined
in my sway/displays.pl script. If no outputs are provided, all available that
are currently enabled will be set.\n
<<<<<<< Updated upstream
--path=<path> Path to wallpaper directory.
-p <path> Default: $ENV{HOME}/wallpapers\n
--daemon=N Configures the wallpaper to be periodically rotated for all
@ -39,12 +40,26 @@ are currently enabled will be set.\n
each rotation, if provided (default: 300).\n
--nocrop Don't crop a selection from the image. Instead, pass the whole
-n image to swaybg and let it handle the scaling\n
=======
--path=<path> Path to wallpaper directory.
-p <path> Default: $ENV{HOME}/wallpapers\n
--daemon=N Configures the wallpaper to be periodically rotated for all
-d N of the given outputs. N indicates the number of seconds between
each rotation, if provided (default: 300).\n
--nocrop Don't crop a selection from the image. Instead, pass the whole
-n image to swaybg and let it handle the scaling\n
>>>>>>> Stashed changes
--verbose=N Define minimum log level. Counting from 1: LOG_DEBUG, LOG_INFO,
-v N LOG_NOTICE, LOG_WARNING, LOG_ERR, LOG_CRIT, LOG_ALERT, LOG_EMERG
Default: 5; If provided without a value for N then all (1).
--recursive=N Enumerate images recursively through directories in the path.
<<<<<<< Updated upstream
-r N N indicates the directory depth, unlimited if no N is provided.
--help This menu
=======
-r N N indicates the directory depth, unlimited if no N is provided.
--help This menu
>>>>>>> Stashed changes
-h\n
You can send SIGUSR1 to force the daemon to reload immediately. Rotation timer
will be reset.\n");
@ -54,6 +69,14 @@ will be reset.\n");
sub new
{
my ($class, %args) = @_;
<<<<<<< Updated upstream
use AnyEvent::Sway;
$args{ipc} = AnyEvent::Sway->new();
use Image::Magick;
$args{im} = Image::Magick->new();
$args{error} = ();
=======
use AnyEvent::Sway;
$args{ipc} = AnyEvent::Sway->new();
@ -65,7 +88,72 @@ sub new
return bless { %args };
}
>>>>>>> Stashed changes
$args{pidfile} = "/tmp/$ENV{USER}-wallpaper.pid";
<<<<<<< Updated upstream
return bless { %args };
}
=======
if (-e $wp->{pidfile}) {
if (-r $wp->{pidfile}) {
if (open(my $fh, '<', $wp->{pidfile})) {
my $pid = <$fh>;
chomp($pid);
use Proc::ProcessTable;
my $pt = Proc::ProcessTable->new();
foreach my $p ( @{ $pt->table() } ) {
if ($p->{pid} eq $pid) {
my $name = $0;
$name =~ s/$ENV{PWD}//;
if ($p->{'cmndline'} =~ m#$name#) {
$wp->do_log("LOG_CRIT", "Another process is already running with PID: $pid (running and listed in $wp->{pidfile})");
# Die locally because do_log will remove pidfile that this iteration does not belong to
exit(1);
} else {
$wp->do_log("LOG_CRIT", "Found matching $pid with different cmdline: $p->{cmndline} (not $0)",1);
# PID in pidfile doesn't look like it is another wallpaper
unlink($wp->{pidfile});
last;
}
return $p->{'pid'};
}
}
} else {
$wp->do_log("LOG_CRIT", "Pidfile $wp->{pidfile} exists, but cannot be opened. Assuming it is running already.");
# Die locally because do_log will remove pidfile that this iteration does not belong to
exit(1);
}
} else {
$wp->do_log("LOG_CRIT", "Pidfile $wp->{pidfile} exists, but is not readable. Assuming it is running already.");
# Die locally because do_log will remove pidfile that this iteration does not belong to
exit(1);
}
}
# SIGUSR reset the timer, force immediate reload, continue looping
$SIG{USR1} = sub {
alarm 0;
$wp->do_log("LOG_INFO", "Reloading due to SIGUSR1");
};
# SIGTERM reset the timer, clean pid, and allow for the main loop to finish run
$SIG{TERM} = sub {
$wp->do_log("LOG_INFO", "Going down clean due to SIGTERM");
clean($wp);
$wp->{daemon} = 0;
};
# SIGKILL clean pid then exit immediately
$SIG{KILL} = sub {
$wp->do_log("LOG_INFO", "Hard kill with SIGKILL, attempting to remove pidfile");
clean($wp);
exit(0);
};
>>>>>>> Stashed changes
# simply returns the array of hashes provided by swaymsg
sub get_outputs
{
@ -151,10 +239,17 @@ sub choose_image
if (-d $_) {
$self->do_log("LOG_DEBUG", "Ignoring sub-directory $_");
next;
<<<<<<< Updated upstream
}
if ($_ =~ m/\.(png|jpg)$/) {
push(@i,$_);
}
=======
}
if ($_ =~ m/\.(png|jpg)$/) {
push(@i,$_);
}
>>>>>>> Stashed changes
}
return $i[rand(scalar(@i))] || return undef;
@ -223,12 +318,21 @@ sub do_log
# Journald is borked. Just don't bother logging
return 0;
if ($self->{daemon}) {
<<<<<<< Updated upstream
#use Log::Journald qw(send);
#send(
#PRIORITY => ERROR->{$level},
#MESSAGE => $msg,
#PERL_PACKAGE => 'Sway Wallpapers'
#) || warn "Could not send log ($level $msg): $!";
=======
use Log::Journald qw(send);
send(
PRIORITY => ERROR->{$level},
MESSAGE => $msg,
PERL_PACKAGE => 'Sway Wallpapers'
) || warn "Could not send log ($level $msg): $!";
>>>>>>> Stashed changes
if ($die) {
$msg = '(FATAL) ' . $msg;
exit(1);
@ -250,7 +354,10 @@ sub run
$self->do_log("LOG_DEBUG", "Fetching outputs from IPC");
$self->{outputs} = $self->get_outputs();
# Local copy of targets so that it will re-check active every time
<<<<<<< Updated upstream
print "Changing $_\n" foreach(@{$self->{targets}});
=======
>>>>>>> Stashed changes
my @t = @{$self->{targets}} if (scalar(@{$self->{targets}}));
$self->do_log("LOG_DEBUG", "Removing inactive ouputs");
my $active = $self->get_active();
@ -261,7 +368,10 @@ sub run
}
$self->do_log("LOG_DEBUG", "Looping desired ouputs");
foreach my $target (@t) {
<<<<<<< Updated upstream
print $target."\n";
=======
>>>>>>> Stashed changes
$self->do_log("LOG_DEBUG", "Ensuring that desired output is active");
unless (defined($active->{$target})) {
$self->do_log('LOG_DEBUG', "Target $target is not an active output");
@ -365,6 +475,7 @@ while (my $arg = shift(@ARGV)) {
die "Redundant argument '$arg'. Recursive search already set.\n" unless ($recursive == 0);
if (scalar(@ARGV) && $ARGV[0] =~ m/^\d+$/) {
$recursive = shift(@ARGV);
<<<<<<< Updated upstream
} else {
$recursive = -1;
}
@ -412,6 +523,15 @@ if (-e $wp->{pidfile}) {
$wp->do_log("LOG_CRIT", "Pidfile $wp->{pidfile} exists, but is not readable. Assuming it is running already.");
# Die locally because do_log will remove pidfile that this iteration does not belong to
exit(1);
=======
} else {
$recursive = -1;
}
} elsif ($arg =~ m/^-/) {
die "Unrecognized argument: $arg\n";
} else {
push(@targets,$arg);
>>>>>>> Stashed changes
}
}

View File

@ -15,6 +15,7 @@ sub usage()
{
print("$0 [value] [-p|--plus] [-m|--minus] [-a x|--attribute=x] [-d N|--delay=N]
Fade the opacity of one or more windows via the Sway IPC interface.\n
<<<<<<< Updated upstream
value The target opacity or offset between 0 (full transparency) and 1
(fully opaque). Change will be made in increments of 0.01 with a
delay between each.\n
@ -27,6 +28,20 @@ value The target opacity or offset between 0 (full transparency) and 1
--delay=N Change the delay in ms between each percentage point change in
-d N opacity. Default: 20\n
--help This menu
=======
value The target opacity or offset between 0 (full transparency) and 1
(fully opaque). Change will be made in increments of 0.01 with a
delay between each.\n
--attribute=x Attribute of window(s) to fade.
-a x Default: [title="*"]\n
--plus Increases opacity by increment instead of setting it directly
-p to that increment.\n
--minus Decreases opacity by increment instead of setting it directly
-m to that increment.\n
--delay=N Change the delay in ms between each percentage point change in
-d N opacity. Default: 20\n
--help This menu
>>>>>>> Stashed changes
-h\n");
exit(0);
}

View File

@ -47,7 +47,10 @@ foreach (@devices) {
close $t;
$output .= '"Type":"' . $type . '"';
if ($name =~ /BAT[0-9]+/) {
<<<<<<< Updated upstream
$nobat = 0;
=======
>>>>>>> Stashed changes
open(my $s,'<',"$_/status");
my $status = <$s>;
chomp $status;
@ -85,10 +88,13 @@ foreach (@devices) {
. '"';
}
$output .= "},";
<<<<<<< Updated upstream
}
unless ($nobat) {
print('{"AC":{"Type":"AC","Status":"Plugged-In"}}');
exit();
=======
>>>>>>> Stashed changes
}
$battery_total{'percentage'} = sprintf("%0d",
@ -109,6 +115,7 @@ if ($bar) {
my $class = 'discharging';
$output = '';
if ($powref->{AC}->{Status} eq "Plugged-In") {
<<<<<<< Updated upstream
$class = 'charging';
$output .= "";
} elsif ($powref->{Total}->{Percentage} <= 10) {
@ -116,6 +123,15 @@ if ($bar) {
$output .= "";
} elsif ($powref->{Total}->{Percentage} <= 35) {
$class = 'low';
=======
$class = 'charging';
$output .= "";
} elsif ($powref->{Total}->{Percentage} <= 10) {
$class = 'critical';
$output .= "";
} elsif ($powref->{Total}->{Percentage} <= 35) {
$class = 'low';
>>>>>>> Stashed changes
$output .= "";
} elsif ($powref->{Total}->{Percentage} <= 60) {
$output .= "";
@ -138,11 +154,19 @@ if ($bar) {
my $total = '';
$output = "Device Status Percentage\n";
foreach my $device (keys %{$powref}) {
<<<<<<< Updated upstream
my $status;
if ($powref->{$device}->{Status} eq "Plugged-In") {
$status = "";
} elsif (!defined($powref->{$device}->{Percentage}) || $powref->{$device}->{Percentage} == 0) {
$status = " ";
=======
my $status;
if ($powref->{$device}->{Status} eq "Plugged-In") {
$status = "";
} elsif (!defined($powref->{$device}->{Percentage}) || $powref->{$device}->{Percentage} == 0) {
$status = " ";
>>>>>>> Stashed changes
} elsif ($powref->{$device}->{Percentage} <= 10) {
$status = " " . $powref->{$device}->{'Percentage'} . "%";
} elsif ($powref->{$device}->{Percentage} <= 35) {
@ -151,6 +175,7 @@ if ($bar) {
$status = " " . $powref->{$device}->{'Percentage'} . "%";
} elsif ($powref->{$device}->{Percentage} <= 85) {
$status = " " . $powref->{$device}->{'Percentage'} . "%";
<<<<<<< Updated upstream
} else {
$status = " " . $powref->{$device}->{'Percentage'} . "%";
}
@ -166,6 +191,23 @@ if ($bar) {
}
$output .= sprintf("%-24s %-12s %-12s\n", $name, $powref->{$device}->{Status}, $status);
}
=======
} else {
$status = " " . $powref->{$device}->{'Percentage'} . "%";
}
if ($device eq 'Total') {
$total .= sprintf("%-24s %-12s", $device, $status);
} else {
#$output .= sprintf("%".length($powref->{$device->{'Type'}})."s (%".length($powref->{$device->{'Type'}})."s): %3d\%\n", $device, $device->{'Type'}, $device->{'Percentage'});
my $name = ' ('.$powref->{$device}->{'Type'}.')';
if ((length($device)+length($name)) >= 24) {
$name = substr($device, 0, (21-length($name))) . '...' . $name;
} else {
$name = substr(($device.$name), 0, 24);
}
$output .= sprintf("%-24s %-12s %-12s\n", $name, $powref->{$device}->{Status}, $status);
}
>>>>>>> Stashed changes
}
$output .= $total;
}

View File

@ -23,9 +23,15 @@ elif [ "$1" == 'upgrade' ]; then
COUNT=`apt list --upgradable 2> /dev/null | wc -l`
let COUNT--
echo $COUNT > /home/jpm/.spool/apt-upgradeable
<<<<<<< Updated upstream
if [ -e /var/run/reboot-required ]; then
grep -B1 -A4 upgrade /var/log/apt/history.log | tail -n 6 | swaynag --config=${HOME}/.dotfiles/sway/swaynag --edge=bottom --message="New packages require restart" --button="Restart Now" "sudo systemctl reboot" --dismiss-button="Later" --detailed-message --detailed-button "Show/Hide Upgrade Details"
fi
=======
if [ -e /var/run/reboot-required ]; then
grep -B1 -A4 upgrade /var/log/apt/history.log | tail -n 6 | swaynag --config=${HOME}/.dotfiles/sway/swaynag --edge=bottom --message="New packages require restart" --button="Restart Now" "sudo systemctl reboot" --dismiss-button="Later" --detailed-message --detailed-button "Show/Hide Upgrade Details"
fi
>>>>>>> Stashed changes
elif [ "$1" == 'update' ]; then
sudo apt update >/dev/null 2>/dev/null
COUNT=`apt list --upgradable 2> /dev/null | wc -l`

View File

@ -6,7 +6,11 @@ swaymsg -t get_tree |
sed -e 's/^\(.*\) [—-] .*$/\1/'|
sed -e 's/^\([0-9]*\)\t*\(.*\)/\2 \1/' |
wofi -s $HOME/.dotfiles/wofi/style.css -c \
<<<<<<< Updated upstream
$HOME/.dotfiles/wofi/sidebar -d | {
=======
$HOME/.dotfiles/wofi/sidebar -d | {
>>>>>>> Stashed changes
read -r
id=`echo $REPLY | rev | cut -d' ' -f1 | rev`
swaymsg "[con_id=$id]" focus