Sway and distrobox scripts
This commit is contained in:
parent
4c5cad9458
commit
ff4f9b43dc
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# distrobox_binary
|
||||||
|
# name: debian12
|
||||||
|
if [ ! -f /run/.containerenv ] && [ ! -f /.dockerenv ]; then
|
||||||
|
command="/usr/bin/distrobox-enter -n debian12 -- /var/home/jpm/scripts/sway/wallpaper.pl --path=/var/home/jpm/wallpapers -d HDMI-A-1 "
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
if echo "${arg}" | grep -Eq "'|\""; then
|
||||||
|
command="${command} \
|
||||||
|
$(echo "${arg}" | sed 's|\\|\\\\|g' |
|
||||||
|
sed 's| |\\ |g' |
|
||||||
|
sed 's|\$|\\\$|g' |
|
||||||
|
sed "s|'|\\\'|g" |
|
||||||
|
sed 's|"|\\\"|g')"
|
||||||
|
elif echo "${arg}" | grep -q "'"; then
|
||||||
|
command="${command} \"${arg}\""
|
||||||
|
else
|
||||||
|
command="${command} '${arg}'"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
eval ${command}
|
||||||
|
else
|
||||||
|
/var/home/jpm/scripts/sway/wallpaper.pl /var/home/jpm/scripts/sway/wallpaper.pl --path=/var/home/jpm/wallpapers -d HDMI-A-1 "$@"
|
||||||
|
fi
|
|
@ -0,0 +1,82 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use AnyEvent::Sway;
|
||||||
|
our $s = AnyEvent::Sway->new();
|
||||||
|
|
||||||
|
sub switch
|
||||||
|
{
|
||||||
|
my $workspace = shift;
|
||||||
|
return defined($s->message(0,"workspace $workspace")->recv->[0]->{'success'});
|
||||||
|
}
|
||||||
|
|
||||||
|
sub move
|
||||||
|
{
|
||||||
|
my $output = shift;
|
||||||
|
return defined($s->message(0,"move workspace to output $output")->recv->[0]->{'success'});
|
||||||
|
}
|
||||||
|
|
||||||
|
sub assign
|
||||||
|
{
|
||||||
|
my $workspace = shift;
|
||||||
|
my $output = shift || die('No output argument given');
|
||||||
|
|
||||||
|
return 0 unless (switch($workspace));
|
||||||
|
return 0 unless (move($output));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $workspaces = {
|
||||||
|
'0' => [ 'DP-1', 'eDP-1' ], # HUD
|
||||||
|
'1' => [ 'DP-1', 'eDP-1' ], # Chat (mattermost, rocket.chat)
|
||||||
|
'2' => [ 'DP-1', 'eDP-1' ], # Mail (thunderbird)
|
||||||
|
'3' => [ 'DP-1', 'eDP-1' ], # Secondary browser (ungoogled chromium)
|
||||||
|
'4' => [ 'DP-1', 'eDP-1' ], # Git (gittyup)
|
||||||
|
'5' => [ 'HDMI-A-1', 'eDP-1' ], # TBD
|
||||||
|
'6' => [ 'HDMI-A-1', 'eDP-1' ], # Terminals (gnome-terminal) - not auto-assigned since they are used everywhere
|
||||||
|
'7' => [ 'HDMI-A-1', 'eDP-1' ], # Browser (firefox)
|
||||||
|
'8' => [ 'HDMI-A-1', 'eDP-1' ], # IDE (neovide, vscode)
|
||||||
|
'9' => [ 'HDMI-A-1', 'eDP-1' ], # Music (WIP)
|
||||||
|
# Miscellaneous Extras
|
||||||
|
'c0' => [ 'DP-1', 'eDP-1' ],
|
||||||
|
'c1' => [ 'DP-1', 'eDP-1' ],
|
||||||
|
'c2' => [ 'DP-1', 'eDP-1' ],
|
||||||
|
'c3' => [ 'DP-1', 'eDP-1' ],
|
||||||
|
'c4' => [ 'DP-1', 'eDP-1' ],
|
||||||
|
'c5' => [ 'HDMI-A-1', 'eDP-1' ],
|
||||||
|
'c6' => [ 'HDMI-A-1', 'eDP-1' ],
|
||||||
|
'c7' => [ 'HDMI-A-1', 'eDP-1' ],
|
||||||
|
'c8' => [ 'HDMI-A-1', 'eDP-1' ],
|
||||||
|
'c9' => [ 'HDMI-A-1', 'eDP-1' ],
|
||||||
|
};
|
||||||
|
|
||||||
|
my $outputs = ($s->get_outputs->recv())[0];
|
||||||
|
my $focused;
|
||||||
|
my %attached;
|
||||||
|
foreach my $o (@{$outputs}) {
|
||||||
|
$focused = $o->{'current_workspace'} if ($o->{'focused'});
|
||||||
|
if ($o->{'active'}) {
|
||||||
|
$attached{$o->{'name'}} = $o->{'current_workspace'};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $w (keys(%{$workspaces})) {
|
||||||
|
foreach my $o (@{$workspaces->{$w}}) {
|
||||||
|
if (defined($attached{$o})) {
|
||||||
|
last() if assign($w, $o);
|
||||||
|
print STDERR ("Failed to assign $w to $o\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Favour for which workspace should be focused at the end should follow this logic:
|
||||||
|
# - Focused window should return to being focused, regardless of the display.
|
||||||
|
# - Any workspaces which were currently visible at the start should be made current again (multiple could be on the same output, pick random)
|
||||||
|
# - Any output which is has neither of the above should just be left with the last switch
|
||||||
|
# Laziest just to switch to those in reverse order, even if it means a few extra switches
|
||||||
|
foreach (keys(%attached)) {
|
||||||
|
switch($attached{$_});
|
||||||
|
}
|
||||||
|
switch($focused);
|
|
@ -76,7 +76,7 @@ my %configs = (
|
||||||
'rotate' => 90,
|
'rotate' => 90,
|
||||||
'scale' => 2,
|
'scale' => 2,
|
||||||
'waybar' => 'top',
|
'waybar' => 'top',
|
||||||
'fallback' => '#fefefe',
|
'fallback' => '#010101',
|
||||||
},
|
},
|
||||||
'TV' => {
|
'TV' => {
|
||||||
'on' => 1,
|
'on' => 1,
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
swaymsg -t get_tree |
|
||||||
|
jq -r '.nodes[].nodes[] | if .nodes then [recurse(.nodes[])] else [] end + .floating_nodes | .[] | select(.nodes==[]) | ((.id | tostring) + " " + .name)' |
|
||||||
|
wofi --show dmenu -c .dotfiles/wofi/sidebar | {
|
||||||
|
read -r id name
|
||||||
|
swaymsg "[con_id=$id]" focus
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Sway window transparency daemon
|
||||||
|
PartOf=graphical-session.target
|
||||||
|
After=sway.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/var/home/jpm/scripts/distrobox/debian12/sway-transparency.sh
|
||||||
|
Restart=unless-stopped
|
||||||
|
Requires=dbus.service
|
||||||
|
After=dbus.service
|
||||||
|
TimeoutSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
|
@ -5,9 +5,9 @@ Description=Rotate through cropped wallpapers for %u
|
||||||
Type=forking
|
Type=forking
|
||||||
#PIDFile=/var/home/%u/.spool/wallpaper.pid
|
#PIDFile=/var/home/%u/.spool/wallpaper.pid
|
||||||
WorkingDirectory=/var/home/%u/.spool
|
WorkingDirectory=/var/home/%u/.spool
|
||||||
ExecStart=/usr/bin/distrobox enter debian12 -- "$HOME/scripts/sway/wallpaper.pl -d --path=/home/jpm/wallpapers `cat $HOME/.spool/wallpaper_outputs`"
|
ExecStart=/var/home/%u/scripts/distrobox/debian12/wallpaper.pl
|
||||||
#ExecStart=/var/home/%u/scripts/sway/wallpaper.pl -d --path=/home/jpm/wallpapers
|
|
||||||
Restart=always
|
Restart=always
|
||||||
|
TimeoutSec=5
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=graphical.target
|
WantedBy=graphical.target
|
||||||
|
|
Loading…
Reference in New Issue