Merge branch 'master' of ssh://git@git.john.me.tz:223/jpm/scripts.git
Conflicts: send-to-kodi.sh sway/displays.pl sway/idle.sh sway/idlecountdown.sh sway/startsway.sh waybar/waybar-fedora-silverblue.sh wofi/wofi-alt-tab.sh
This commit is contained in:
commit
abc0b9f097
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# TODO replace `zenity` with `wofi`
|
||||
|
||||
# Required settings
|
||||
host=192.168.2.66
|
||||
port=8080
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
swaymsg "[pid=$(echo $ALACRITTY_LOG | sed -E 's/\/tmp\/Alacritty-(.*)\.log/\1/')] urgent enable"
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/env python3
|
||||
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
|
||||
def handle_container(con):
|
||||
"""
|
||||
Recursively find all windows
|
||||
"""
|
||||
|
||||
windows = []
|
||||
|
||||
if 'app_id' in con.keys():
|
||||
app_id = con['id']
|
||||
app_name = con['app_id'] if con['app_id'] else con['window_properties']['class']
|
||||
app_title = con['name']
|
||||
|
||||
windows.append((app_id, app_name, app_title,))
|
||||
|
||||
for child in con['nodes']:
|
||||
windows = windows + handle_container(child)
|
||||
|
||||
return windows
|
||||
|
||||
|
||||
tree = json.loads(subprocess.check_output(['swaymsg', '-t', 'get_tree']))
|
||||
windows = []
|
||||
|
||||
# Find all workspaces and the windows in them
|
||||
for output in tree['nodes']:
|
||||
for workspace in output['nodes']:
|
||||
if 'nodes' not in workspace.keys():
|
||||
continue
|
||||
|
||||
for container in workspace['nodes']:
|
||||
windows = windows + handle_container(container)
|
||||
for container in workspace['floating_nodes']:
|
||||
windows = windows + handle_container(container)
|
||||
|
||||
# Format the list of windows for dmenu/rofi
|
||||
windows_string = '\n'.join([f"<{app_id}> {app_name} --- {app_title}" for app_id, app_name, app_title in windows])
|
||||
|
||||
# Call rofi and move focus to the selected window
|
||||
selection = subprocess.check_output(['wofi', '-s', '/home/jpm/.dotfiles/wofi/style.css', '-c', '/home/jpm/.dotfiles/wofi/sidebar', '-d'], input=windows_string, universal_newlines=True)
|
||||
window_id = selection.split(' ')[0][1:-1]
|
||||
subprocess.call(['swaymsg', f"[con_id=\"{window_id}\"]", 'focus'])
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
flatpak run com.github.Eloston.UngoogledChromium --app="https://papillon.john.me.tz/hud.php?theme=dark&refresh=3600"
|
||||
|
104
sway/idle.sh
104
sway/idle.sh
|
@ -1,50 +1,76 @@
|
|||
#!/bin/bash
|
||||
|
||||
BLFILE="/home/jpm/.config/blc.last"
|
||||
OPFILE="/home/jpm/.config/active_outputs"
|
||||
BLFILE="/home/jpm/.spool/idle.dim"
|
||||
OPFILE="/home/jpm/.spool/active_outputs"
|
||||
|
||||
FADE_TIMEOUT=60 # one minute
|
||||
DIM_TIMEOUT=120 # two minutes
|
||||
LOCK_TIMEOUT=300 # five minutes
|
||||
DPMS_TIMEOUT=600 # ten minutes
|
||||
SUSPEND_TIMEOUT=3600 # one hour
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo "usage: $0 <option>
|
||||
start - Initialize 'swayidle' script. This should be declared in Sway config.
|
||||
stop - Kill 'swayidle' script. Consider idle-inhibitor instead.
|
||||
fade - First idle action. Fades all windows to show background.
|
||||
unfade - Restore opacity for faded windows.
|
||||
dim - Reduce display brightness to minimum.
|
||||
undim - Restore brightness to level prior to 'dim'.
|
||||
lock - Mark as inactive and start 'swaylock'.
|
||||
unlock - (Run upon unlock) Mark as active again.
|
||||
sleep - Disable displays, but continue background processes.
|
||||
wake - Re-enable displays.
|
||||
suspend - Hibernate.
|
||||
help - This message."
|
||||
exit
|
||||
}
|
||||
|
||||
if [ -z $1 ]; then
|
||||
echo "Missing argument: start, warn, lock, unlock, sleep, wake, or resume"
|
||||
echo "Missing argument"
|
||||
usage
|
||||
elif [ $1 == "-h" ] || [ $1 == "--help" ] || [ $1 == "help" ]; then
|
||||
usage
|
||||
elif [ $1 == "start" ]; then
|
||||
swayidle -w timeout 270 "/home/jpm/scripts/sway/idle.sh warn" \
|
||||
resume "/home/jpm/scripts/sway/idle.sh resume" \
|
||||
timeout 300 "/home/jpm/scripts/sway/idle.sh sleep" \
|
||||
resume "/home/jpm/scripts/sway/idle.sh wake" \
|
||||
before-sleep "/usr/bin/swaylock -c 000000"
|
||||
elif [ $1 == "warn" ]; then
|
||||
# Store current brightness
|
||||
echo $(/home/jpm/scripts/thinkpad/blc.pl %) > $BLFILE
|
||||
# Dim display
|
||||
/home/jpm/scripts/thinkpad/blc.pl = 1
|
||||
# Warning notifications
|
||||
/home/jpm/scripts/sway/idlecountdown.sh
|
||||
swayidle -w \
|
||||
timeout $FADE_TIMEOUT "$0 fade" \
|
||||
resume "$0 unfade" \
|
||||
timeout $DIM_TIMEOUT "$0 dim" \
|
||||
resume "$0 undim" \
|
||||
timeout $LOCK_TIMEOUT "$0 lock" \
|
||||
resume "$0 unlock" \
|
||||
timeout $DPMS_TIMEOUT "$0 sleep" \
|
||||
resume "$0 wake" \
|
||||
timeout $SUSPEND_TIMEOUT "$0 suspend"
|
||||
elif [ $1 == "stop" ]; then
|
||||
pkill swayidle
|
||||
elif [ $1 == "fade" ]; then
|
||||
$HOME/scripts/sway/fade.pl start
|
||||
elif [ $1 == "unfade" ]; then
|
||||
$HOME/scripts/sway/fade.pl stop
|
||||
elif [ $1 == "dim" ]; then
|
||||
echo $($HOME/scripts/thinkpad/blc.pl %) > $BLFILE
|
||||
$HOME/scripts/thinkpad/blc.pl = 1 &>-
|
||||
elif [ $1 == "undim" ]; then
|
||||
$HOME/scripts/thinkpad/blc.pl = `cat $BLFILE` &>-
|
||||
elif [ $1 == "lock" ]; then
|
||||
echo $(/home/jpm/scripts/thinkpad/blc.pl %) > $BLFILE
|
||||
/home/jpm/scripts/thinkpad/blc.pl = 1
|
||||
ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
|
||||
'screen -S irssi -X stuff "/nick jpmAFK^M"'
|
||||
elif [ $1 == "unlock" ]; then
|
||||
/home/jpm/scripts/thinkpad/blc.pl = `cat $BLFILE`
|
||||
elif [ $1 == "sleep" ]; then
|
||||
# Change nick to AFK
|
||||
ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
|
||||
'screen -S irssi -X stuff "/nick jpmAFK^M"'
|
||||
# Turn off monitor
|
||||
#for i in `cat $OPFILE`; do swaymsg "output $i dpms off"; done
|
||||
#ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
|
||||
#'screen -S irssi -X stuff "/nick jpmAFK^M"'
|
||||
:
|
||||
elif [ $1 == "unlock" ]; then
|
||||
# Change nick to AFK
|
||||
#ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
|
||||
#'screen -S irssi -X stuff "/nick jpm^M"'
|
||||
:
|
||||
elif [ $1 == "sleep" ]; then
|
||||
for i in `cat $OPFILE`; do swaymsg "output $i dpms off"; done
|
||||
elif [ $1 == "wake" ]; then
|
||||
# Kill additional counters that might have been started
|
||||
/home/jpm/scripts/sway/idle.sh resume
|
||||
# Restore output(s)
|
||||
/home/jpm/scripts/sway/displays.pl
|
||||
#for i in `cat $OPFILE`; do swaymsg "output $i dpms on"; done
|
||||
# Lock screen
|
||||
swaylock -c 000000
|
||||
# Restore brightness level
|
||||
/home/jpm/scripts/thinkpad/blc.pl = $(cat $BLFILE)
|
||||
elif [ $1 == "resume" ]; then
|
||||
# Kill warning
|
||||
for i in `pkill idlecountdown`; do kill $i; done
|
||||
/home/jpm/scripts/thinkpad/blc.pl = $(cat $BLFILE)
|
||||
elif [ $1 == "suspend" ]; then
|
||||
sudo systemctl start hibernate.target
|
||||
else
|
||||
echo "Invalid argument: start, warn, lock, unlock, sleep, wake, or resume"
|
||||
echo "Invalid argument: $1"
|
||||
usage
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Gtk2::Notify -init, "Idle";
|
||||
use Time::HiRes qw( gettimeofday usleep );
|
||||
|
||||
my $start = [gettimeofday];
|
||||
my $now = sprintf("%.0f",($start->[0]*1000) + ($start->[1]/1000));
|
||||
my $end = $now + 30000;
|
||||
|
||||
while ($now < $end) {
|
||||
my $remaining = ($end - $now);
|
||||
my $notification = Gtk2::Notify::new('Idle', sprintf("%.0f",($remaining/1000)), '', "status_lock");
|
||||
$notification->set_hint_string('x-canonical-private-synchronous','idle');
|
||||
$notification->set_urgency('NOTIFY_URGENCY_LOW');
|
||||
$notification->set_hint_int32('value',($remaining/300));
|
||||
$notification->set_timeout(150);
|
||||
$notification->show();
|
||||
usleep(100);
|
||||
$now = utime( undef, undef );
|
||||
$start = [gettimeofday];
|
||||
$now = sprintf("%.0f",($start->[0]*1000) + ($start->[1]/1000));
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
for i in `seq 0 30`; do
|
||||
notify-send -t 999 "Sleeping" $(expr 30 - $i); sleep 1
|
||||
notify-send -a 'swayidle' -t 999 "Sleeping" $(expr 30 - $i); sleep 1
|
||||
done
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/bash
|
||||
rm $HOME/.swaylog
|
||||
echo sway > $HOME/.spool/last_login_gui
|
||||
<<<<<<< HEAD
|
||||
export SSH_AUTH_SOCK=~/.ssh/ssh-agent.sock
|
||||
export SWAYSOCK="$HOME/.spool/sway-ipc.sock"
|
||||
export QT_QPA_PLATFORM="wayland-egl;wayland;xcb"
|
||||
|
@ -21,3 +22,10 @@ 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`
|
||||
=======
|
||||
export SWAYSOCK="$HOME/.spool/sway-ipc.sock"
|
||||
#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`
|
||||
systemctl --user stop wallpapers.service
|
||||
>>>>>>> master
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our $debug = 1; # For testing, will output configuration and errors if true
|
||||
|
||||
use AnyEvent::Sway;
|
||||
our $s = AnyEvent::Sway->new();
|
||||
|
||||
our $o = $s->get_outputs->recv();
|
||||
die "No outputs detected.\n" unless (scalar(@$o) > 1);
|
||||
|
||||
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
|
||||
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
|
||||
-h\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
sub set_opacity
|
||||
{
|
||||
my $attribute = shift || return "No target or image provided";
|
||||
my $target = shift || return "No image provided";
|
||||
# TODO get fallback from javascript
|
||||
my $cmd = "output $attribute opacity $target";
|
||||
print "Running $cmd\n";
|
||||
my $ret = $s->message(0,$cmd)->recv;
|
||||
if ($ret->[0]->{success}) {
|
||||
print "Success!\n";
|
||||
return undef;
|
||||
}
|
||||
return "Failed to run Sway IPC command '$cmd'";
|
||||
}
|
||||
|
||||
my @targets;
|
||||
my $daemon = 0;
|
||||
my $delay = 300;
|
||||
my $crop = 1;
|
||||
my $path;
|
||||
|
||||
while (my $arg = shift(@ARGV)) {
|
||||
if ($arg eq '-h' || $arg eq '--help') {
|
||||
usage();
|
||||
} elsif ($arg =~ m/^\-\-path=?(.+)$/) {
|
||||
die "Redundant argument '$arg'. Wallpaper path already set.\n" if ($path);
|
||||
$path = $1;
|
||||
} elsif ($arg eq '-p') {
|
||||
die "Redundant argument '$arg'. Wallpaper path already set.\n" if ($path);
|
||||
$path = shift(@ARGV);
|
||||
} elsif ($arg =~ m/^\-\-daemon=?(.+)$/) {
|
||||
die "Redundant argument '$arg'. Daemon mode already set.\n" if ($daemon);
|
||||
$delay = $1;
|
||||
$daemon = 1;
|
||||
} elsif ($arg eq '-d') {
|
||||
die "Redundant argument '$arg'. Daemon mode already set.\n" if ($daemon);
|
||||
if ($ARGV[0] =~ m/^\d+$/) {
|
||||
$delay = shift(@ARGV);
|
||||
}
|
||||
$daemon = 1;
|
||||
} elsif ($arg eq '--nocrop' || $arg eq '-') {
|
||||
die "Redundant argument '$arg'. No-crop already set.\n" unless ($crop);
|
||||
} else {
|
||||
push(@targets,$arg);
|
||||
}
|
||||
}
|
||||
|
||||
die "Invalid rotation delay: $delay" unless ($delay =~ m/^\d+$/);
|
||||
|
||||
if ($path) {
|
||||
die "Invalid wallpaper path '$path'. Not a directory." unless (-d $path);
|
||||
} else {
|
||||
$path = "$ENV{HOME}/wallpapers";
|
||||
}
|
||||
|
||||
if (scalar(@targets)) {
|
||||
my @kept;
|
||||
foreach my $t (@targets) {
|
||||
my $hit = 0;
|
||||
foreach (@$o) {
|
||||
if ($_->{name} eq $t) {
|
||||
push(@kept, $t);
|
||||
$hit++;
|
||||
last;
|
||||
}
|
||||
}
|
||||
print STDERR "Requested output '$t' not found\n" unless ($hit);
|
||||
}
|
||||
die "None of the requested outputs are active" unless (scalar(@kept));
|
||||
@targets = @kept;
|
||||
}
|
||||
|
||||
if ($daemon) {
|
||||
my $p = fork();
|
||||
if ($p) {
|
||||
print "Daemonized as PID: $p\n";
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
print "Initial configuration:\n";
|
||||
print " Targets: ( " . ( join(" ",@targets) || "All active" ) . " )\n";
|
||||
print " Daemon: $daemon\n";
|
||||
print " Path: $path\n";
|
||||
}
|
||||
|
||||
my @e;
|
||||
do {
|
||||
my @err;
|
||||
# Local copy of targets so that it will re-check active every time
|
||||
my @t = @targets;
|
||||
unless (scalar(@t)) {
|
||||
@t = get_active();
|
||||
push(@err, "No target outputs") unless (scalar(@t));
|
||||
}
|
||||
foreach my $a (@t) {
|
||||
my $image = choose_image($path);
|
||||
if (defined($image)) {
|
||||
if ( -r "$image" ) {
|
||||
print "selected $image\n";
|
||||
my $cropped;
|
||||
if ($crop) {
|
||||
if ($debug) {
|
||||
print "Cropping image for '$a' using '$image'\n";
|
||||
}
|
||||
my ($ow, $oh) = get_size($a);
|
||||
$cropped = crop($image, $ow, $oh);
|
||||
unless ($cropped) {
|
||||
push(@err, "Failed to generate cropped image") unless ($cropped);
|
||||
next;
|
||||
}
|
||||
} else {
|
||||
$cropped = $image;
|
||||
}
|
||||
my $e = set_background($a,$cropped);
|
||||
push(@err, $e) if (defined($e));
|
||||
if ($crop) {
|
||||
print "Deleting $cropped\n";
|
||||
#unlink($cropped) || push(@err, "Failed to delete $cropped after setting: $!");
|
||||
}
|
||||
} else {
|
||||
push(@err, "$a: Unable to read image $image");
|
||||
}
|
||||
} else {
|
||||
push(@err, "$a: Unable to select image from $path");
|
||||
}
|
||||
}
|
||||
if ($debug && $daemon) {
|
||||
print STDERR join("\n",@err);
|
||||
sleep($delay);
|
||||
} else {
|
||||
@e = @err;
|
||||
}
|
||||
} while ($daemon);
|
||||
|
||||
if (scalar(@e)) {
|
||||
die "Failure while not running as daemon:\n" .
|
||||
join("\n",@e);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
COUNT=0
|
||||
function count() {
|
||||
RESULTS="`rpm-ostree upgrade --check 2> /dev/null | grep 'rpm-md repo' | cut -d: -f3`;"
|
||||
RESULTS="`rpm-ostree upgrade --check 2> /dev/null | grep Diff: | sed 's/.*\([0-9][0-9]*\).*/\1/'`"
|
||||
COUNT=0
|
||||
for i in $RESULTS; do
|
||||
i=`echo $i | sed 's/;//'`
|
||||
|
|
|
@ -5,6 +5,7 @@ swaymsg -t get_tree |
|
|||
sed -e 's/^.*\-\- \(.*\)$/\1/' |
|
||||
sed -e 's/^\(.*\) [—-] .*$/\1/'|
|
||||
sed -e 's/^\([0-9]*\)\t*\(.*\)/\2 \1/' |
|
||||
<<<<<<< HEAD
|
||||
wofi -s $HOME/.dotfiles/wofi/style.css -c \
|
||||
$HOME/.dotfiles/wofi/sidebar -d | {
|
||||
read -r
|
||||
|
@ -12,3 +13,10 @@ swaymsg -t get_tree |
|
|||
swaymsg "[con_id=$id]" focus
|
||||
}
|
||||
echo $id $REPLY
|
||||
=======
|
||||
wofi -I -s /home/jpm/.dotfiles/wofi/style.css -c \
|
||||
$HOME/.dotfiles/wofi/sidebar --show dmenu | {
|
||||
read -r id name
|
||||
swaymsg "[con_id=$id]" focus
|
||||
}
|
||||
>>>>>>> master
|
||||
|
|
Loading…
Reference in New Issue