Permalink
Find file
0c2e9bb May 7, 2016
executable file 36 lines (28 sloc) 1.18 KB
#!/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 - $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://