tadly / hideIt.sh

Automagically hide/show a window by its name when the cursor is within a defined region or you mouse over it.
GNU General Public License v3.0
248 stars 11 forks source link

How to use on a dual monitor setup ? #15

Closed f3bruary closed 3 years ago

f3bruary commented 3 years ago

I have a 1366x768 laptop with an external monitor 1920x1080 (left of the laptop).

I'm using this script to wrap polybar so it's displayed on both monitors:

if type "xrandr"; then
  for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
    MONITOR=$m polybar --reload example &
  done
else
  polybar --reload example &
fi

My monitors are:

#Laptop 
WM_NAME(STRING) = "polybar-example_LVDS1"
#Monitor
WM_NAME(STRING) = "polybar-example_HDMI1"

Could you perhaps explain how I can best use hideit.sh and set my region(s) ?

Also: I rarely detach the monitor, but it would be great if this would kept working while dis-/connecting the monitor. Although, if it's too complex I can live without it.

f3bruary commented 3 years ago

I worked it out with:

hideIt.sh --name "^polybar-example_HDMI1$" -H -d bottom -p 1 hideIt.sh --name "^polybar-example_LVDS1$" -H -d bottom -p 313

Funny that the laptop requires a peek of 313 (312+768=1080), to compensate for the external monitor :) I imagine if I detach the monitor, I need to change this to 1 again (for minimal peek).

tadly commented 3 years ago

I'm really sorry for my late response. Started a new job and had hell of a week ':D

Glad you found a solution. The 313 peek is probably though to this where I fetch the screen dimensions and pretty much ignore if there are multiple.

I honestly did not write this with multi-monitor setups in mind (though I clearly should have). From the top of my head I can't think of an easy solution to add multi-monitor support and as I'm very pressed on time lately I'm not sure if I'll get around to it anytime soon :/

I'll keep thinking about it, maybe a nice and easy solution comes to mind at some point but for now I think it would take a lot of rewriting

tadly commented 3 years ago

Actually... I might just be stupid..

If fetch_screen_dimensions would fetch the dimensions of the screen where the window is located, this would probably fix it. I'll try to find some time tomorrow. You'll have to do the testing though as I don't have a secondary screen :)

f3bruary commented 3 years ago

No worries man, it's just a 1st world problem. Congrats on your new job !

Yeah, sure I'm willing to test it. For now, I've merged the hideit commands in my startup script (I use sleep 6 cause it seems I need to wait a but until Polybar is fully loaded before I start hideit):

if type "xrandr"; then
  for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
      if [ $m = 'LVDS1' ]; then
          MONITOR=$m polybar --reload example &
          sleep 6
          hideIt.sh --name "^polybar-example_LVDS1$" -H -d bottom -p 313 &
      fi
      if [ $m = 'HDMI1' ]; then
          MONITOR=$m polybar --reload example &
          sleep 6
          hideIt.sh --name "^polybar-example_HDMI1$" -H -d bottom -p 1 &
      fi
  done
else
  polybar --reload example &
fi
moukle commented 3 years ago

Did have the same issue with top hiding. Computing to = win_height + peek - win_pos did it.

diff --git a/hideIt.sh b/hideIt.sh
index 9c925e2..fb186fd 100755
--- a/hideIt.sh
+++ b/hideIt.sh
@@ -457,7 +457,7 @@ function hide_window() {
         fi

     elif [ "$DIRECTION" == "top" ]; then
-        to=-$(($WIN_HEIGHT - $PEEK))
+        to=$((-$WIN_HEIGHT + $PEEK + $WIN_POSY))
         if [ $hide -eq 0 ]; then
             sequence=($(seq $WIN_POSY -$STEPS $to))
             sequence+=($to)

Thanks for your tool :+1: