Cleanup and update paths
This commit is contained in:
parent
cd362eea6f
commit
5c3a10ce76
|
@ -28,20 +28,18 @@
|
|||
# "output": __OUTPUT__
|
||||
# "position": __POSITION__
|
||||
# "width": __WIDTH__ (optional)
|
||||
my $waybar_template = "$ENV{'HOME'}/.config/waybar/config.template";
|
||||
my $waybar_template = "$ENV{'HOME'}/.dotfiles/waybar/config.template";
|
||||
|
||||
#my $swaysock = "/home/jpm/.config/sway-ipc.sock";
|
||||
my $swaysock = `ls /run/user/1000/sway-ipc.1000*`;
|
||||
chomp($swaysock);
|
||||
my $swaysock = $ENV{'SWAYSOCK'} || $ENV{'HOME'} . "/.spool/sway-ipc.sock";
|
||||
|
||||
# Path to actual config file generated from template
|
||||
my $waybar_config = "$ENV{'HOME'}/.config/waybar/config";
|
||||
|
||||
# File to log and recover last used layout name
|
||||
my $last = "$ENV{'HOME'}/.config/last_display";
|
||||
my $last = "$ENV{'HOME'}/.spool/last_display";
|
||||
|
||||
# File to log active outputs (used by swayidle, and to attempt to restore
|
||||
my $active_outputs = "$ENV{'HOME'}/.config/active_outputs";
|
||||
my $active_outputs = "$ENV{'HOME'}/.spool/active_outputs";
|
||||
|
||||
########################################################################
|
||||
# Display Serials and Names
|
||||
|
@ -88,7 +86,7 @@ my %configs = (
|
|||
'rotate' => 0,
|
||||
'scale' => 1.333333333,
|
||||
'waybar' => 'top',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
},
|
||||
'eDP-1' => {
|
||||
'on' => 1,
|
||||
|
@ -98,7 +96,7 @@ my %configs = (
|
|||
'y' => 0,
|
||||
'rotate' => 0,
|
||||
'waybar' => 'bottom',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
}
|
||||
},
|
||||
'detached' => {
|
||||
|
@ -122,7 +120,7 @@ my %configs = (
|
|||
'y' => 0,
|
||||
'rotate' => 0,
|
||||
'waybar' => 'bottom',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
}
|
||||
},
|
||||
'stacked-laptop' => {
|
||||
|
@ -134,7 +132,7 @@ my %configs = (
|
|||
'y' => 0,
|
||||
'rotate' => 0,
|
||||
'waybar' => 'bottom',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
},
|
||||
'HP-1' => {
|
||||
'on' => 1,
|
||||
|
@ -144,7 +142,7 @@ my %configs = (
|
|||
'y' => 1200,
|
||||
'rotate' => 0,
|
||||
'waybar' => 'top',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
},
|
||||
'HP-2' => {
|
||||
'on' => 0
|
||||
|
@ -160,7 +158,7 @@ my %configs = (
|
|||
'y' => 1200,
|
||||
'rotate' => 0,
|
||||
'waybar' => 'bottom',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
}
|
||||
},
|
||||
'stacked' => {
|
||||
|
@ -172,7 +170,7 @@ my %configs = (
|
|||
'y' => 0,
|
||||
'rotate' => 0,
|
||||
'waybar' => 'bottom',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
},
|
||||
'HP-1' => {
|
||||
'on' => 1,
|
||||
|
@ -182,7 +180,7 @@ my %configs = (
|
|||
'y' => 1200,
|
||||
'rotate' => 0,
|
||||
'waybar' => 'top',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
},
|
||||
'HP-2' => {
|
||||
'on' => 1,
|
||||
|
@ -192,7 +190,7 @@ my %configs = (
|
|||
'y' => 1200,
|
||||
'rotate' => 0,
|
||||
'waybar' => 'top',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
},
|
||||
'TV' => {
|
||||
'on' => 0
|
||||
|
@ -210,7 +208,7 @@ my %configs = (
|
|||
'y' => 225,
|
||||
'rotate' => 270,
|
||||
'waybar' => 'top',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
},
|
||||
'Sam' => {
|
||||
'on' => 1,
|
||||
|
@ -220,7 +218,7 @@ my %configs = (
|
|||
'y' => 0,
|
||||
'rotate' => 90,
|
||||
'waybar' => 'top',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
},
|
||||
'HP-2' => {
|
||||
'on' => 1,
|
||||
|
@ -230,7 +228,7 @@ my %configs = (
|
|||
'y' => 225,
|
||||
'rotate' => 90,
|
||||
'waybar' => 'top',
|
||||
'fallback' => '#000000'
|
||||
'fallback' => '#282828'
|
||||
},
|
||||
'TV' => {
|
||||
'on' => 0
|
||||
|
@ -312,11 +310,12 @@ if (!defined($configs{$config})) {
|
|||
}
|
||||
|
||||
# Write config that is to be used so that it can be recovered as default
|
||||
open(my $fh, '>', $last) ||
|
||||
print STDERR "Config name cannot be written to $last\n";
|
||||
print $fh $config;
|
||||
close($fh);
|
||||
|
||||
if (open(my $fh, '>', $last)) {
|
||||
print $fh $config;
|
||||
close($fh);
|
||||
} else {
|
||||
print STDERR "Config name cannot be logged to: $last\n";
|
||||
}
|
||||
|
||||
# Fetch connected displays
|
||||
use JSON::XS;
|
||||
|
@ -468,7 +467,7 @@ foreach my $out (keys %$on) {
|
|||
|
||||
# Sway returns status as JSON
|
||||
my $res_raw = `$cmd`;
|
||||
print $res_raw . "\n";
|
||||
#print $res_raw . "\n";
|
||||
my $res = $json->decode($res_raw)->[0];
|
||||
|
||||
# If failed, print to STDERR
|
||||
|
@ -508,9 +507,13 @@ foreach my $out (keys %$on) {
|
|||
}
|
||||
}
|
||||
|
||||
open($fh, '>', $active_outputs);
|
||||
print $fh join(' ', @active);
|
||||
close($fh);
|
||||
# Log active outputs for recovery after crash/reboot
|
||||
if (open(my $fh, '>', $active_outputs)) {
|
||||
print $fh join(' ', @active);
|
||||
close($fh);
|
||||
} else {
|
||||
print STDERR "Cannot write active outputs to: $active_outputs\n";
|
||||
}
|
||||
|
||||
# Restore array formatting
|
||||
$waybar = '[' . $waybar . ']';
|
||||
|
@ -522,9 +525,12 @@ unless ($pid) {
|
|||
open STDOUT, '>>/dev/null';
|
||||
open STDERR, '>>/dev/null';
|
||||
# Write config to a temporary file
|
||||
open ($fh, '>', $waybar_config);
|
||||
print $fh $waybar;
|
||||
close $fh;
|
||||
if (open (my $fh, '>', $waybar_config)) {
|
||||
print $fh $waybar;
|
||||
close $fh;
|
||||
} else {
|
||||
die "Failed to write configuration file: $waybar_config\n";
|
||||
}
|
||||
my $waydisplay = $ENV{'WAYLAND_DISPLAY'} || 'wayland-0';
|
||||
`WAYLAND_DISPLAY=$waydisplay nohup waybar -b waybar0 --config=$waybar_config >> waybar.log; /home/jpm/scripts/waybar/toggle.sh invert`;
|
||||
`WAYLAND_DISPLAY=$waydisplay nohup waybar -b waybar0 --config=$waybar_config >> $ENV{'HOME'}/.waybar.log`;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue