-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebcam_overlay.sh
executable file
·35 lines (28 loc) · 1.18 KB
/
webcam_overlay.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
# Settings
CAM_WIDTH=320
CAM_HEIGHT=240
DEVICE=/dev/video0
# To keep the overlay on all workspaces (Ubuntu 14.04):
#
# 1. Focus on the webcam overlay window, press Alt+Space to open context menu
# and select 'Always on Visible Workspace'; or
# 2. Install 'compizconfig-settings-manager' and 'compiz-plugins', open up
# compiz settings manager, enable 'Windows Rules' plugin and add to
# 'Sticky' rule: 'class=MPlayer'. This will make every MPlayer window to
# be always visible.
# Make sure 'mplayer' is available
if ! type "mplayer" > /dev/null; then
echo "You need to install 'mplayer' first."
exit 1
fi
# Get current screen width and height
SCREEN_WIDTH=$(xdpyinfo | awk -F'[ x]+' '/dimensions:/{print $3}')
SCREEN_HEIGHT=$(xdpyinfo | awk -F'[ x]+' '/dimensions:/{print $4}')
# Calculate horizontal and vertical offset to position the webcam overlay at
# bottom right corner
HORIZONTAL_OFFSET=$(expr $SCREEN_WIDTH / 2 - $CAM_WIDTH)
VERTICAL_OFFSET=$(expr $SCREEN_HEIGHT - $CAM_HEIGHT)
mplayer -ontop -noborder \
-geometry ${CAM_WIDTH}x${CAM_HEIGHT}+${HORIZONTAL_OFFSET}+${VERTICAL_OFFSET} \
-tv driver=v4l2:width=${CAM_WIDTH}:height=${CAM_HEIGHT}:device=${DEVICE} tv://