Skip to content

Commit 375d408

Browse files
committed
use xininfo
1 parent 374e596 commit 375d408

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

teiler

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -152,30 +152,23 @@ stopRecording () {
152152
notify-send -t "1" "teiler" "Stopped recording"; output=$(xininfo -name); xrandr --output "$output" --auto; return 0
153153
}
154154

155-
156155
ffmpegCmd () {
157156
if [[ $1 == "fullscreen" ]]; then
158-
x="$(teiler_helper --resolution | grep "x=" | awk -F "x=" '{ print $2 }')"
159-
y="$(teiler_helper --resolution | grep "y=" |awk -F "y=" '{ print $2 }')"
160-
xoff="$(teiler_helper --resolution | grep "xoff=" | awk -F "xoff=" '{ print $2 }')"
161-
yoff="$(teiler_helper --resolution | grep "yoff=" | awk -F "yoff=" '{ print $2 }')"
162157
isRecording && { notify "$time" 'Screencast already in progress'; echo "Already recording Screen"; exit 1; }
163158
ffmpeg_display=$(echo $DISPLAY)
164-
ffmpeg_offset=$(echo $(( ${xoff} -1 )),${yoff})
165-
res_now="${x}x${y}"
159+
ffmpeg_offset=$(echo $(( $(xininfo -mon-x) -1 )),$(xininfo -mon-y))
160+
res_now="$(echo $(xininfo -mon-size | awk '{ print $1 }')x$(xininfo -mon-size | awk '{ print $2 }'))"
166161
if [[ $res_now == $res ]]; then echo " "
167162
else output=$(xininfo -name); xrandr --output "$output" --mode "$res"; sleep 5; fi
168-
169163
[[ -f "${vid_path}/${filename}.mp4" ]] && rm "${vid_path}/${filename}.mp4"
170164
if [[ -z $ffaudio ]]; then $encoder -f x11grab -s $res -i $ffmpeg_display+$ffmpeg_offset $encopts "${vid_path}/${filename}.mp4" &
171165
else $encoder -f x11grab -s $res -i $ffmpeg_display+$ffmpeg_offset $ffaudio $encopts "${vid_path}/${filename}.mp4" &
172166
fi
173167
echo "$!" > "$SCREENCAST_PIDFILE"
174168
notify-send -t "1" "teiler" "Screencast started"
175-
176169
elif [[ $1 == "area" ]]; then
177170
isRecording && { notify "$time" 'Screencast already in progress'; echo "Already recording Screen"; exit 1; }
178-
ffmpeg_display=$(echo $DISPLAY); ffmpeg_offset="${xoff},${yoff}"; eval `slop -b "$slop_border" -c "$slop_color"`
171+
ffmpeg_display=$(echo $DISPLAY); ffmpeg_offset=$(echo $(xininfo -mon-x),$(xininfo -mon-y)); eval `slop -b "$slop_border" -c "$slop_color"`
179172
[[ -f "${vid_path}/${filename}.mp4" ]] && rm "${vid_path}/${filename}.mp4"
180173
if [[ -z $ffaudio ]]; then $encoder -f x11grab -s "$(( $W - 1))"x"$(( $H - 1))" -i $ffmpeg_display+$X,$Y $rect_encopts "${vid_path}/${filename}.mp4" &
181174
else $encoder -f x11grab -s "$(( $W -1 ))"x"$(( $H - 1 ))" -i $ffmpeg_display+$X,$Y $ffaudio $rect_encopts "${vid_path}/${filename}.mp4" &
@@ -187,17 +180,13 @@ ffmpegCmd () {
187180
}
188181

189182
maimCmd () {
190-
x="$(teiler_helper --resolution | grep "x=" | awk -F "x=" '{ print $2 }')"
191-
y="$(teiler_helper --resolution | grep "y=" | awk -F "y=" '{ print $2 }')"
192-
xoff="$(teiler_helper --resolution | grep "xoff=" | awk -F "xoff=" '{ print $2 }')"
193-
yoff="$(teiler_helper --resolution | grep "xoff=" | awk -F "yoff=" '{ print $2 }')"
194183
if [[ $1 == "delay" ]]; then
195-
if [[ $2 == "area" ]]; then maim -s -w "${x}" -h "${y}" -x "${xoff}" -y "${yoff}" -d ${delay} "${img_path}/${3}.png";
196-
elif [[ $2 == "fullscreen" ]]; then maim -w "${x}" -h "${y}" -x "${xoff}" -y "$yoff}" -d ${delay} "${img_path}/${3}.png";
184+
if [[ $2 == "area" ]]; then maim -s -w $(xininfo -mon-width) -h $(xininfo -mon-height) -x $(xininfo -mon-x) -y $(xininfo -mon-y) -d ${delay} "${img_path}/${3}.png";
185+
elif [[ $2 == "fullscreen" ]]; then maim -w $(xininfo -mon-width) -h $(xininfo -mon-height) -x $(xininfo -mon-x) -y $(xininfo -mon-y) -d ${delay} "${img_path}/${3}.png";
197186
elif [[ $2 == "fullscreenAll" ]]; then maim -d ${delay} "${img_path}/${3}.png"; fi
198187
elif [[ $1 == "nodelay" ]]; then
199-
if [[ $2 == "area" ]]; then maim -s -w "${x}" -h "${y}" -x "${xoff}" -y "${yoff}" "${img_path}/${3}.png";
200-
elif [[ $2 == "fullscreen" ]]; then maim -w "${x}" -h "${y}" -x "${xoff}" -y "${yoff}" "${img_path}/${3}.png";
188+
if [[ $2 == "area" ]]; then maim -s -w $(xininfo -mon-width) -h $(xininfo -mon-height) -x $(xininfo -mon-x) -y $(xininfo -mon-y) "${img_path}/${3}.png";
189+
elif [[ $2 == "fullscreen" ]]; then maim -w $(xininfo -mon-width) -h $(xininfo -mon-height) -x $(xininfo -mon-x) -y $(xininfo -mon-y) "${img_path}/${3}.png";
201190
elif [[ $2 == "fullscreenAll" ]]; then maim "${img_path}/${3}.png"; fi
202191
fi
203192
}

0 commit comments

Comments
 (0)