-
Notifications
You must be signed in to change notification settings - Fork 1
/
vars.sh
executable file
·71 lines (63 loc) · 2.5 KB
/
vars.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# This file should `source`d.
# Only $DIR is required to `source` this file.
if [ ! ${I3MSG:+1} ] # Don't execute this file multiple times
then
if ! touch "${DIR}"/.mpv-input-DONTEDIT.conf
then
>&2 echo Exiting because failed to create "${DIR}"/.mpv-input-DONTEDIT.conf
exit 1
fi
#cat "$MPV__INPUT_CONF" | grep -iv ' pause ' | sed -r 's/CTRL\+//ig' | perl -pe 's/format=fmt=[^:"]+(?::colorlevels=limited:colormatrix=auto)?//g' > "${MPV__INPUT_CONF}"
#| perl -pe 's/(ctrl\+a )no-osd set vf "format=fmt=yuv444p10:colorlevels=limited:colormatrix=auto";/$1/gi' \
#| perl -pe 's/format=fmt=[^:"]+(?::colorlevels=limited:colormatrix=auto)?//g' \
cat "$MPV__INPUT_CONF" \
| perl -pe 's/(ctrl\+[ao] no-osd set vf ")format=fmt=yuv444p10:colorlevels=limited:colormatrix=auto";/$1";/gi' \
| grep -iv ' pause | speed |loop-file' \
| sed -r 's/CTRL\+//ig' \
> "${DIR}"/.mpv-input-DONTEDIT.conf
#format=fmt=[^:"]+(?::colorlevels=limited:colormatrix=auto)?//g' > "${MPV__INPUT_CONF}"
export MPV__INPUT_CONF="${DIR}"/.mpv-input-DONTEDIT.conf
HOST_I3SOCK=`i3 --get-socketpath | tr -d "\n"`
export HOST_DISPLAY=${HOST_DISPLAY:-${DISPLAY}}
export HOST_WAYLAND_DISPLAY=${WAYLAND_DISPLAY}
export HOST_RES=${HOST_RES:-$(xdpyinfo | grep imensions | grep -Eo '[0-9]+x[0-9]+ pixels' | grep -Eo '[0-9]+x[0-9]+' )}
# \d+x\d+(?= pixels)
#^example HOST_RES value is 1920x1080
export HOST_W=$(echo -n "${HOST_RES}" | sed -r 's/x.+//g')
export HOST_H=$(echo -n "${HOST_RES}" | sed -r 's/[0-9]+x//g')
if [[ "${__GLX_VENDOR_LIBRARY_NAME}" == "nvidia" ]]
then
if [[ ! ${HOST_W:+1} ]] # sometimes this file is included by a file which already included vars.sh
then
echo
echo
echo "You already have environment variable __GLX_VENDOR_LIBRARY_NAME=nvidia, don't forget"
echo
export isNvidia=1
fi
else
if [[ ! ${__GLX_VENDOR_LIBRARY_NAME:+1} ]]
then
(nvidia-smi | grep '[MG]iB')>/dev/null 2>/dev/null && \
echo 'Setting env var __GLX_VENDOR_LIBRARY_NAME to `nvidia` instead of default `mesa` because it seems you use an NVIDIA GPU' && echo && \
export __GLX_VENDOR_LIBRARY_NAME=nvidia && \
export isNvidia=1
#&& export __NV_PRIME_RENDER_OFFLOAD=1 && \
#export __VK_LAYER_NV_optimus=NVIDIA_only && \
#export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-0
else
# FIXME: or do not set it?
#echo "Setting __GLX_VENDOR_LIBRARY_NAME=mesa"
#export __GLX_VENDOR_LIBRARY_NAME=mesa
export isNvidia=0
fi
fi
if [ ${SWAYSOCK:+1} ]
then
I3MSG=swaymsg
else
I3MSG=i3-msg
fi
XDOTOOL=xdotool
fi