Update displays.pl

This commit is contained in:
John Mertz 2023-10-24 11:05:50 -06:00
parent a2719e8c43
commit 671bc03816
1 changed files with 37 additions and 6 deletions

View File

@ -1,5 +1,9 @@
#!/usr/bin/perl
use v5.36;
#no warnings 'builtin::blessed';
#use experimental qw( builtin::blessed );
# TODO: push list with dynamic wallpapers to ~/.spool/wallpaper_outputs
########################################################################
# Usage
@ -16,7 +20,7 @@
# Dependencies
########################################################################
#
# Depends on JSON::XS and Proc::ProcessTable
# Depends on JSON::MaybeXS and Proc::ProcessTable
#
# Debian:
# apt install libjson-xs-perl libproc-processtable-perl
@ -37,7 +41,8 @@ my $swaysock = $ENV{'SWAYSOCK'} || $ENV{'HOME'} . "/.spool/sway-ipc.sock";
my $waybar_config = "$ENV{'HOME'}/.config/waybar/config";
# Path to waybar binary
my $waybar_bin = "$ENV{'HOME'}/.dotfiles/nix/bin/waybar";
#my $waybar_bin = "$ENV{'HOME'}/.dotfiles/nix/bin/waybar";
my $waybar_bin = "/usr/bin/waybar";
# File to log and recover last used layout name
my $last = "$ENV{'HOME'}/.spool/last_display";
@ -132,7 +137,7 @@ my %configs = (
'bg' => "$ENV{HOME}/wallpapers/wallpaper.png"
},
},
'detached' => {
'x1' => {
'x1' => {
'on' => 1,
'width' => 2560,
@ -145,6 +150,32 @@ my %configs = (
'fallback' => '#010101',
'bg' => "$ENV{HOME}/wallpapers/wallpaper.png"
},
'x13' => {
'on' => 0
},
'eInk' => {
'on' => 0
},
'TV' => {
'on' => 0
}
},
'x13' => {
'x1' => {
'on' => 0
},
'x13' => {
'on' => 1,
'width' => 2560,
'height' => 1440,
'x' => 0,
'y' => 0,
'rotate' => 0,
'scale' => 1.5,
'waybar' => 'bottom',
'fallback' => '#010101',
'bg' => "$ENV{HOME}/wallpapers/wallpaper.png"
},
'eInk' => {
'on' => 0
},
@ -246,8 +277,8 @@ if (open(my $fh, '>', $last)) {
}
# Fetch connected displays
use JSON::XS;
my $json = JSON::XS->new();
use JSON::MaybeXS;
my $json = JSON::MaybeXS->new();
my $displays_raw = `swaymsg -s $swaysock -t get_outputs --raw`;
my $displays = $json->decode($displays_raw);
@ -319,7 +350,7 @@ unless ($waybar_only) {
# Kill existing Waybars
require Proc::ProcessTable;
my $t = new Proc::ProcessTable;
my $t = Proc::ProcessTable->new();
foreach my $p ( @{ $t->table } ) {
my $cmndline = $p->{'cmndline'};
$cmndline =~ s/\s*$//g;