lot o updates

This commit is contained in:
2021-07-21 14:00:12 -04:00
parent b2be5c0d4a
commit f444d5693a
11 changed files with 374 additions and 58 deletions

91
i3/compton.conf Normal file
View File

@@ -0,0 +1,91 @@
## Shadow
#shadow = true;
#no-dnd-shadow = true;
#no-dock-shadow = true;
#clear-shadow = true;
#shadow-radius = 7;
#shadow-offset-x = -7;
#shadow-offset-y = -7;
## shadow-opacity = 0.7;
## shadow-red = 0.0;
## shadow-green = 0.0;
## shadow-blue = 0.0;
#shadow-exclude = [
# "name = 'Notification'",
# "class_g = 'Conky'",
# "class_g ?= 'Notify-osd'",
# "class_g = 'Cairo-clock'",
# "_GTK_FRAME_EXTENTS@:c"
#];
## shadow-exclude = "n:e:Notification";
## shadow-exclude-reg = "x10+0+0";
## xinerama-shadow-crop = true;
#
## Opacity
#menu-opacity = 0.8;
#inactive-opacity = 0.8;
## active-opacity = 0.8;
#frame-opacity = 0.7;
#inactive-opacity-override = false;
#alpha-step = 0.06;
## inactive-dim = 0.2;
## inactive-dim-fixed = true;
## blur-background = true;
## blur-background-frame = true;
#blur-kern = "3x3box";
## blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1";
## blur-background-fixed = true;
#blur-background-exclude = [
# "window_type = 'dock'",
# "window_type = 'desktop'",
# "_GTK_FRAME_EXTENTS@:c"
#];
## opacity-rule = [ "80:class_g = 'URxvt'" ];
#
## Fading
#fading = true;
## fade-delta = 30;
#fade-in-step = 0.03;
#fade-out-step = 0.03;
## no-fading-openclose = true;
## no-fading-destroyed-argb = true;
#fade-exclude = [ ];
#
## Other
#backend = "xrender";
#mark-wmwin-focused = true;
#mark-ovredir-focused = true;
## use-ewmh-active-win = true;
#detect-rounded-corners = true;
#detect-client-opacity = true;
#refresh-rate = 0;
#vsync = "none";
#dbe = false;
#paint-on-overlay = true;
## sw-opti = true;
## unredir-if-possible = true;
## unredir-if-possible-delay = 5000;
## unredir-if-possible-exclude = [ ];
#focus-exclude = [ "class_g = 'Cairo-clock'" ];
#detect-transient = true;
#detect-client-leader = true;
#invert-color-include = [ ];
## resize-damage = 1;
#
## GLX backend
## glx-no-stencil = true;
#glx-copy-from-front = false;
## glx-use-copysubbuffermesa = true;
## glx-no-rebind-pixmap = true;
#glx-swap-method = "undefined";
## glx-use-gpushader4 = true;
## xrender-sync = true;
## xrender-sync-fence = true;
#
## Window type settings
#wintypes:
#{
# tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; };
#};
#
opacity-rule = ["10:name = 'i3lock'"]

View File

@@ -123,44 +123,32 @@ bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym j resize shrink width 10 px or 10 ppt
bindsym k resize grow height 10 px or 10 ppt
bindsym l resize shrink height 10 px or 10 ppt
bindsym semicolon resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
tray_output primary
status_command i3status
}
# Custom stats
# Custom config
default_border pixel 1
exec $HOME/.screenlayout/main.sh
workspace 1 output HDMI-A-1
workspace 2 output HDMI-A-0
#workspace 3 output DVI-I-1
exec $HOME/.screenlayout/dock.sh
# Only moves workspace if output
workspace 1 output DP-0
workspace 2 output DP-0
workspace 3 output eDP-1-1
workspace 4 output eDP-1-1
workspace 10 output eDP-1-1
# Move whole workspace
bindsym $mod+o move workspace to output left
bindsym $mod+p move workspace to output right
# Change between laptop/dock
bindsym $mod+Shift+o exec $HOME/.screenlayout/dock.sh
bindsym $mod+Shift+p exec $HOME/.screenlayout/laptop.sh
# Misc
bindsym $mod+Shift+f focus parent; fullscreen; focus child
#i3lock
bindsym $mod+x exec i3lock -c 000000
bindsym $mod+x exec $HOME/.config/i3/matrixlock.py

98
i3/matrixlock.py Executable file
View File

@@ -0,0 +1,98 @@
#!/usr/bin/python3
from argparse import ArgumentParser
from http.server import BaseHTTPRequestHandler, HTTPServer
from os.path import dirname, join
from subprocess import run, Popen, DEVNULL
from threading import Thread, Event
from time import time
import json
def main(matrix_delay_secs):
workspaces = get_workspaces()
visible = [ws for ws in workspaces if ws['visible']]
with SubprocessServer(('', 0), len(visible)) as server:
port = server.server_address[1]
for ws in visible:
overlay_matrix_on_workspace(ws['name'], port, matrix_delay_secs)
run(['i3lock', '-n'], check=True)
for pid_path in server.received_posts:
assert pid_path.startswith('/'), pid_path
try:
pid = int(pid_path[1:])
except ValueError:
continue
run(['kill', str(pid)])
def get_workspaces():
cp = run(
['i3-msg', '-t', 'get_workspaces'],
capture_output=True, check=True, text=True
)
return json.loads(cp.stdout)
def overlay_matrix_on_workspace(ws_name, port, delay):
run([
'i3-msg',
f'workspace {ws_name}; '
# There may already be a full-screen app on that workspace.
# This would prevent us from showing the Matrix full-screen.
# So disable fullscreen first.
f'fullscreen disable; '
# --color-text=black to hide the cursor when there is a delay.
f'exec "xfce4-terminal --hide-scrollbar --hide-menubar --fullscreen --color-text=black '
# Send child PID to server so the parent can kill it, then show Matrix:
f'-x bash -c \'curl -X POST localhost:{port}/$$ && sleep {delay} && cmatrix -b\'"'
], check=True, stdout=DEVNULL)
class SubprocessServer(HTTPServer):
"""
Process up to num_requests POST requests in up to timeout_secs seconds and
store their paths in self.received_posts.
"""
def __init__(self, server_address, num_requests, timeout_secs=5):
super().__init__(server_address, SubprocessHandler)
self.received_posts = []
self._num_requests = num_requests
self._timeout_secs = timeout_secs
self._thread = Thread(target=self._run_in_thread)
self._started = Event()
self._timeout_encountered = False
def __enter__(self):
result = super().__enter__()
self._thread.start()
self._started.wait()
return result
def __exit__(self, *args, **kwargs):
self._thread.join()
def _run_in_thread(self):
self._started.set()
end = time() + self._timeout_secs
for _ in range(self._num_requests):
time_remaining = end - time()
if time_remaining < 0:
break
self.timeout = time_remaining
self.handle_request()
if self._timeout_encountered:
break
def handle_timeout(self):
self._timeout_encountered = True
class SubprocessHandler(BaseHTTPRequestHandler):
def do_POST(self):
self.server.received_posts.append(self.path)
self.send_response(200)
self.end_headers()
def log_message(self, format, *args):
return
if __name__ == '__main__':
parser = ArgumentParser(description='Alternative to i3lock that displays the Matrix')
parser.add_argument(
'delay', type=int, nargs='?', default=0,
help='Seconds between blanking out the screen and starting the Matrix'
)
args = parser.parse_args()
main(args.delay)