aboutsummaryrefslogtreecommitdiff
path: root/xlock
blob: 87a86dd0cffb0ce5b78cdbbb71b852688f167d9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
#
# Lock the screen of a X11 session
#

# Get current focused window
# Some screen lockers such as i3lock loose the window focus
WINDOW="`xdotool getwindowfocus`"

# Using xscreensaver
#xscreensaver-command --lock

# Using i3lock
i3lock -c 1c1c1c

# See https://www.kirsle.net/turn-off-monitor-from-linux-cli
#     https://askubuntu.com/questions/62858/turn-off-monitor-using-command-line#62861
sleep 1
xset dpms force off

# Restore focus
xdotool windowfocus $WINDOW