add automatic transparency script
This commit is contained in:
parent
a74ebdfe05
commit
cc53a3230e
2 changed files with 76 additions and 4 deletions
|
@ -261,7 +261,6 @@ in {
|
|||
'';
|
||||
};
|
||||
programs.kitty.settings = with theme; {
|
||||
background_opacity = "0.85";
|
||||
background = color 0;
|
||||
foreground = color 15;
|
||||
cursor = color 15;
|
||||
|
@ -464,7 +463,6 @@ in {
|
|||
border = mkLiteral "3px";
|
||||
border-color = mkLiteral "@border-col";
|
||||
background-color = mkLiteral "@bg-col";
|
||||
opacity = mkLiteral "0.9";
|
||||
};
|
||||
mainbox = {
|
||||
background-color = mkLiteral "@bg-col";
|
||||
|
@ -615,7 +613,16 @@ in {
|
|||
mantle = color 0;
|
||||
crust = color 0;
|
||||
};
|
||||
"glassit.alpha" = 220;
|
||||
"glassit.force_sway" = true;
|
||||
};
|
||||
systemd.user.services.transparency = {
|
||||
Unit = {
|
||||
Description = "transparency";
|
||||
After = ["graphical-session-pre.target"];
|
||||
PartOf = ["graphical-session.target"];
|
||||
};
|
||||
Install.WantedBy = ["graphical-session.target"];
|
||||
Service = {
|
||||
ExecStart = "${./transparency.py}";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
65
config/programs/transparency.py
Executable file
65
config/programs/transparency.py
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i python3 -p python3 python3Packages.i3ipc
|
||||
|
||||
import i3ipc
|
||||
import signal
|
||||
import sys
|
||||
from functools import partial
|
||||
|
||||
foreground_transparency = "0.9"
|
||||
background_transparency = "0.7"
|
||||
|
||||
|
||||
def on_window_focus(ipc, event):
|
||||
global prev_focused
|
||||
|
||||
focused = event.container
|
||||
|
||||
if focused.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859
|
||||
if focused.fullscreen_mode > 0:
|
||||
focused.command("opacity 1")
|
||||
else:
|
||||
focused.command("opacity " + foreground_transparency)
|
||||
if prev_focused.fullscreen_mode == 0:
|
||||
prev_focused.command("opacity " + background_transparency)
|
||||
prev_focused = focused
|
||||
|
||||
|
||||
def on_fullscreen_mode(ipc, event):
|
||||
global prev_focused
|
||||
if event.container.id == prev_focused.id:
|
||||
prev_focused = event.container
|
||||
|
||||
if event.container.fullscreen_mode > 0:
|
||||
event.container.command("opacity 1")
|
||||
elif event.container.focused:
|
||||
event.container.command("opacity " + foreground_transparency)
|
||||
else:
|
||||
event.container.command("opacity " + background_transparency)
|
||||
|
||||
|
||||
def remove_opacity(ipc):
|
||||
for workspace in ipc.get_tree().workspaces():
|
||||
for w in workspace:
|
||||
w.command("opacity 1")
|
||||
ipc.main_quit()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ipc = i3ipc.Connection()
|
||||
prev_args = None
|
||||
|
||||
for window in ipc.get_tree():
|
||||
if window.fullscreen_mode > 0:
|
||||
window.command("opacity 1")
|
||||
elif window.focused:
|
||||
prev_focused = window
|
||||
window.command("opacity " + foreground_transparency)
|
||||
else:
|
||||
window.command("opacity " + background_transparency)
|
||||
for sig in [signal.SIGINT, signal.SIGTERM]:
|
||||
signal.signal(sig, lambda signal, frame: remove_opacity(ipc))
|
||||
ipc.on("window::focus", on_window_focus)
|
||||
ipc.on("window::fullscreen_mode", on_fullscreen_mode)
|
||||
ipc.main()
|
Loading…
Reference in a new issue