i3 / i3lock

improved screen locker
https://i3wm.org/i3lock
BSD 3-Clause "New" or "Revised" License
921 stars 404 forks source link

A brief look at the active application before the lockscreen loads up #240

Closed Lattitude75 closed 4 years ago

Lattitude75 commented 5 years ago

My setup is the following: I use i3wm on Plasma desktop with SDDM on Arch Linux. I have noticed, since the very beginning, that when my laptop wakes up from sleep the KDE lockscreen comes up with the password prompt. The lockscreen takes a few seconds to load and meanwhile the window, on which I was working before my laptop went to suspend, shows up. This happens before the lockscreen shows and thus before I put in my password. This is not secure and is a serious issue as my active window is clearly shown even though for a couple of seconds.

I also noticed another issue. Since I use the Plasma background apps and services, the location of the KDE notifications sometimes shows up in the centre of the screen randomly. This only happens when I login into my user and the location stays the same. For example, if I find that the notification showed up in the centre of the screen, it stays the same for the rest of the session. I tried to use the i3wm config for the location and also use a script to redirect the window to the specific location. The script is shown below(I took the following script from some post I don't remember where. I am sorry for not citing the source). The problem still persists.

My log file is: https://logs.i3wm.org/logs/5645139984777216.bz2 I will provide you with any other info as needed.

#!/usr/bin/env bash

################# GET INFO of current screen
OFFSET_RE="\+([-0-9]+)\+([-0-9]+)"

# Get the active window position
unset x y w h
eval $(xwininfo -id $(xdotool getactivewindow) |
  sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
         -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
         -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
         -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )

# Loop through each screen and compare the offset with the window position (top left) to find the active monitor
monitor_index=0
while read name width height xoff yoff
do
    if [ "${x}" -ge "$xoff" \
      -a "${y}" -ge "$yoff" \
      -a "${x}" -lt "$(($xoff+$width))" \
      -a "${y}" -lt "$(($yoff+$height))" ]
    then
        monitor=$name
        break
    fi
    ((monitor_index++))
done < <(xrandr | grep " connected 1\| connected primary 1" |
    sed -r "s/^([^ ]*).*\b([-0-9]+)x([-0-9]+)$OFFSET_RE.*$/\1 \2 \3 \4 \5/" |
    sort -nk4,5)

# If we found the active monitor, move the notifications window there.
if [ ! -z "$monitor" ]
then
    win_id=$(xdotool search --onlyvisible --classname plasmashell | tail -1)
    i3-msg [id="$win_id"]  move output $monitor
    exit 0
else
    echo "Couldn't find any monitor for the current window." >&2
    exit 1
fi 

Environment

Output of i3 --moreversion 2>&-:

Binary i3 version:  4.16.1 (2019-01-27) © 2009 Michael Stapelberg and contributors
Running i3 version: 4.16.1 (2019-01-27) (pid 738) abort…)
Loaded i3 config: /home/saipavanc/.config/i3/config (Last modified: Mon 15 Jul 2019 07:52:40 PM IST, 245 seconds ago)

The i3 binary you just called: /usr/bin/i3
The i3 binary you are running: /usr/bin/i3 
            
i3bot commented 5 years ago

I don’t see a link to logs.i3wm.org. Did you follow https://i3wm.org/docs/debugging.html? (In case you actually provided a link to a logfile, please ignore me.)

Airblader commented 5 years ago

My immediate thought is that your system triggers the lockscreen on wakeup rather than before allowing the machine to go to sleep.

Lattitude75 commented 5 years ago

I don’t see a link to logs.i3wm.org. Did you follow https://i3wm.org/docs/debugging.html? (In case you actually provided a link to a logfile, please ignore me.)

I am sorry. I will include it right away.

Lattitude75 commented 5 years ago

My immediate thought is that your system triggers the lockscreen on wakeup rather than before allowing the machine to go to sleep.

Is there any way I would know if that is the case by following the journal logs?

Lattitude75 commented 5 years ago

@Airblader I did not understand how I should go about solving it. Is this an issue with my set-up or the plasma screenlocker? Is it that this is not the right place for me to ask this question? Cause I don't get any reply.

Airblader commented 5 years ago

Is it that this is not the right place for me to ask this question?

You can also ask on /r/i3wm, you may get some help there as well. Not that we wouldn't help you here (though I did migrate the issue to the correct repository now), but on reddit you'll have far more users reading actively along.

At the moment I don't have the time to look into this myself (sorry).

stapelberg commented 4 years ago

I don’t know about the specifics of how i3lock is started in your environment, but I will note that when using xss-lock, this happens by default unless you specify --transfer-sleep-lock, at which point i3lock can pass control back to xss-lock (which then proceeds with suspending) after the screen is locked.

So, perhaps using xss-lock with the --transfer-sleep-lock option helps?

Lattitude75 commented 4 years ago

I know it has been a long while, but I wanted to show the solution I adopted. I used a systemd service file which can be activated on a per-user basis to include a sleep delay just before the sleep.

suspend@.service:

[Unit]
Description=User suspend actions
Before=sleep.target

[Service]
User=%I
Type=oneshot
Environment=DISPLAY=:0
ExecStart=/usr/bin/sleep 2
NOW=$(date +%%s); \
if [[ $(pacmd list-sink-inputs | grep -c 'state: RUNNING') > 0 ]]; then echo "Playing";fi;\
/usr/bin/sleep 2\
'
#ExecStartPost=/usr/bin/sleep 1

[Install]
WantedBy=sleep.target

Now, the system waits for about a couple of seconds before it goes to sleep to wait for the lockscreen to finish its job. I do not mind a couple of second wait, so it's fine for me.