From 46ba941d0e3df93c243429551bd5101b0c1c172e Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 8 Mar 2023 18:09:07 +0800 Subject: update --- cleanfullscreen | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 cleanfullscreen (limited to 'cleanfullscreen') diff --git a/cleanfullscreen b/cleanfullscreen new file mode 100755 index 0000000..0e94ad8 --- /dev/null +++ b/cleanfullscreen @@ -0,0 +1,97 @@ +#!/bin/sh +# Clean fullscreen aims to provide a means to have a clean desktop when using +# transparency in bspwm, the issue I found was that when a window entered, +# fullscreen mode I was still able to see the windows behind it, I think this +# looks kind of gross so that's why this exists. + +HideBar() { + polybar-msg cmd hide +} + +ShowBar() { + polybar-msg cmd show +} + +HideNodes() { + for node in $1; do + bspc node "$node" -g hidden=on + done +} + +HideTiled() { + Nodes=$(bspc query -N -n .tiled -d "$1") + HideNodes "$Nodes" +} + +ShowNodes() { + Nodes=$(bspc query -N -n .hidden -d "$1") + + for node in $Nodes; do + bspc node "$node" -g hidden=off + done +} + +bspc subscribe node_state | while read -r Event Monitor Desktop Node State Active +do + PrimaryMonitor=$(bspc query -M -m primary) + # Hide bar and nodes when node becomes fullscreen, otherwise show + if [ "$State" = "fullscreen" ] && [ "$Active" = "on" ]; then + # Only consider nodes on primary monitor + if [ "$PrimaryMonitor" = "$Monitor" ]; then + HideBar + fi + HideTiled "$Desktop" + else + if [ "$PrimaryMonitor" = "$Monitor" ]; then + ShowBar + fi + ShowNodes "$Desktop" + fi +done & + +bspc subscribe node_remove | while read Event Monitor Desktop Node +do + PrimaryMonitor="$(bspc query -M -m primary)" + + # Show bar if no nodes are fullscreen on current desktop + if [ "$Monitor" = "$PrimaryMonitor" ] && \ + [ -z "$(bspc query -N -n .fullscreen -d "$Desktop")" ]; then + ShowBar + fi + ShowNodes "$Desktop" +done & + +bspc subscribe node_transfer | while read -r Event SrcMonitor SrcDesktop SrcNode DestMonitor Dest Desktop DestNode +do + # Show nodes on src desktop and hide nodes on dest desktop + # If src node is in full screen mode + if [ -n "$(bspc query -N -n "$SrcNode".fullscreen)" ]; then + ShowNodes "$SrcDesktop" + HideTiled "$DestDesktop" + ShowBar + fi + + # Hide any fullscreen nodes on destination desktop + FullscreenDest=$(bspc query -N -n .fullscreen -d "$DestDesktop" \ + | sed "/$SrcNode/d") + if [ -n "$FullscreenDest" ]; then + HideNodes "$FullscreenDest" + fi +done & + +bspc subscribe desktop_focus | while read -r Event Monitor Desktop +do + PrimaryMonitor="$(bspc query -M -m primary)" + FullscreenNode="$(bspc query -N -n .fullscreen -d "$Desktop")" + + # Only consider nodes on primary monitor + if [ "$PrimaryMonitor" = "$Monitor" ]; then + # Hide bar if desktop contains fullscreen node + if [ -n "$FullscreenNode" ]; then + HideBar + # Otherwise show the bar + else + ShowBar + fi + fi +done & -- cgit v1.2.3