Compare commits

...

3 Commits

Author SHA1 Message Date
John Mertz a2719e8c43 Create simplified `flatpak run` script 2023-10-19 12:40:50 -06:00
John Mertz 0563b42684 Run wireguard as user 2023-10-19 12:39:51 -06:00
John Mertz 8552974810 Allow single space in SSID 2023-10-19 11:54:41 -06:00
3 changed files with 67 additions and 5 deletions

View File

@ -8,16 +8,16 @@ if [ $res = "Connection" ]; then
/usr/bin/uxterm -e 'sudo /usr/bin/nmtui'
elif [ $res = "John.Me.tz" ]; then
sudo /usr/bin/systemctl stop openvpn-client@mailcleaner
sudo /usr/bin/systemctl restart wg-quick@wg0
/usr/bin/systemctl --user restart wg-quick@wg0
elif [ $res = "MailCleaner" ]; then
sudo /usr/bin/systemctl stop wg-quick@wg0
/usr/bin/systemctl --user stop wg-quick@wg0
sudo /usr/bin/systemctl restart openvpn-client@mailcleaner
elif [ $res = "Disconnect" ]; then
sudo /usr/bin/systemctl stop openvpn-client@mailcleaner
sudo /usr/bin/systemctl stop wg-quick@wg0
/usr/bin/systemctl --user stop wg-quick@wg0
elif [ $res = "Restart" ]; then
if [ "`ip addr show wg0 2> /dev/null`" != "" ]; then
sudo /usr/bin/systemctl restart wg-quick@wg0
/usr/bin/systemctl --user restart wg-quick@wg0
fi
if [ "`ip addr show tun0 2> /dev/null`" != "" ]; then
sudo /usr/bin/systemctl restart openvpn-client@mailcleaner

View File

@ -46,7 +46,7 @@ elif [ "$CHENTRY" = "Toggle Off" ]; then
else
# If the connection is already in use, then this will still be able to get the SSID
CHSSID=$(echo "$CHENTRY" | cut -d' ' -f1)
CHSSID=$(echo "$CHENTRY" | sed 's/ .*//')
CURRSSID=$(echo "$CHENTRY" | grep '\*')
if [ -n "$CURRSSID" ]; then
nmcli con down "$CHSSID"

62
sway/flatpak-run.pl Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/env perl
# Simplify `flatpak run`
use strict;
use warnings;
use v5.36;
my $input = shift(@ARGV) || die("Requires at least 1 argument\n");
my @list = split(/\n/, `flatpak list`);
shift(@list);
my %apps;
for my $line (@list) {
my ($name, $id, $version, $branch) = split(/\t/, $line);
next if ($id =~ /\b(Platform|Codecs)\b/);
$apps{$name} = $id;
}
# Exact name match first
run($apps{$input}, @ARGV) if (defined($apps{$input}));
# Case-insensitive name match next
foreach (keys(%apps)) {
print("Case-insensitive name match\n") if ($_ =~ m/^$input$/i);
run($apps{$_}, @ARGV) if ($_ =~ m/^$input$/i);
}
# Exact final id stanza next
foreach (keys(%apps)) {
print("Exact id match\n") if ($apps{$_} =~ m/\.$input$/);
run($apps{$_}, @ARGV) if ($apps{$_} =~ m/\.$input$/);
}
# Case-insensitive final id stanza next
foreach (keys(%apps)) {
print("Case-insensitive id match\n") if ($apps{$_} =~ m/\.$input$/i);
run($apps{$_}, @ARGV) if ($apps{$_} =~ m/\.$input$/i);
}
# Fuzzy name match
foreach (keys(%apps)) {
print("Fuzzy name match\n") if ($_ =~ m/$input/i);
run($apps{$_}, @ARGV) if ($_ =~ m/$input/i);
}
# Fuzzy id match
foreach (keys(%apps)) {
print("Fuzzy id match\n") if ($apps{$_} =~ m/$input/i);
run($apps{$_}, @ARGV) if ($apps{$_} =~ m/$input/i);
}
sub run($id, @args)
{
printf("Running $id ".join(' ',@args)."\n");
my $pid = fork();
if ($pid) {
exit();
} else {
system("/usr/bin/flatpak run $id ".join(' ', @args));
exit();
}
}