Skip to content

Fixed uninstall #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ install:
install -Dm 644 data/acpid/LID_display-visor ${DESTDIR}${SYSCONFDIR}/acpi/events/LID_display-visor
install -Dm 744 data/systemd-sleep/WAKEUP_display-visor.sh ${DESTDIR}${LIBDIR}/systemd/system-sleep/WAKEUP_display-visor.sh
install -Dm 755 src/display-visor ${DESTDIR}${PREFIX}/bin/display-visor

uninstall:
rm ${SYSCONFDIR}/udev/rules.d/90-HOTPLUG_display-visor.rules
rm ${SYSCONFDIR}/acpi/events/LID_display-visor
rm ${LIBDIR}/systemd/system-sleep/WAKEUP_display-visor.sh
rm ${DESTDIR}${PREFIX}/display-visor
rm ${DESTDIR}${PREFIX}/bin/display-visor
2 changes: 1 addition & 1 deletion data/udev/90-HOTPLUG_display-visor.rules
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="pkill -RTMIN+5 display-visor"
ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="/usr/bin/pkill -x -RTMIN+5 display-visor"
54 changes: 16 additions & 38 deletions src/display-visor
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ usage ()
-i, --i3 Test for i3wm instance.
For avoiding conflict with multiple environments.
-l, --lid Check laptop lid status.
Ignored/Assumed closed if not given.
Ignored/Assumed closed if not given.
It is possible to specify switch. Defaults to 'LID0'
If unsure, look under /proc/acpi/button/lid/...
-v, --version Print version info.
Expand Down Expand Up @@ -85,15 +85,17 @@ declare_outputs ()
status=$(cat $l)
dev=$(echo $dir | cut -d\- -f 2-)

if [ $(expr match $dev "HDMI") != "0" ]; then
dev=HDMI${dev#HDMI-?-}
if [ $(expr match $dev "DP") != "0" ]; then
dev=DP${dev#DP?}
else
dev=$(echo $dev | tr -d '-')
fi

if [ "connected" == "$status" ]; then
echo "$prefix $dev connected"
declare -gA $dev="yes"
else
unset $dev
fi
done <<< "$devices"
}
Expand All @@ -106,25 +108,13 @@ config_closed_lid ()
elif [ -n "$LVDS1" -a -z "$lidtest" ]; then
echo "$prefix Laptop display will be ignored unless -l option is set"
fi
if [ -n "$HDMI1" -a -n "$VGA1" ]; then
echo "$prefix SETTING: HDMI1 (Primary) - VGA1 (Right)"
if [ -n "$DP1" ]; then
echo "$prefix SETTING: DP1 (Primary) - VGA1 (Right)"
xrandr --output LVDS1 --off \
--output HDMI1 --auto --primary \
--output VGA1 --auto --right-of HDMI1
elif [ -n "$HDMI1" -a -z "$VGA1" ]; then
echo "$prefix SETTING: HDMI1 (Primary)"
xrandr --output LVDS1 --off \
--output VGA1 --off \
--output HDMI1 --auto --primary
elif [ -z "$HDMI1" -a -n "$VGA1" ]; then
echo "$prefix SETTING: VGA1 (Primary)"
xrandr --output LVDS1 --off \
--output HDMI1 --off \
--output VGA1 --auto --primary
--output DP1 --auto --primary \
else
echo "$prefix No external monitors are plugged in"
xrandr --output HDMI1 --off \
--output VGA1 --off \
xrandr --output DP1 --off \
--output LVDS1 --auto --primary
fi
}
Expand All @@ -133,26 +123,14 @@ config_closed_lid ()
config_open_lid ()
{
echo "$prefix Laptop lid is open"
if [ -n "$HDMI1" -a -n "$VGA1" ]; then
echo "$prefix SETTING: LVDS1 (Left) - HDMI1 (Primary) - VGA1 (Right)"
xrandr --output LVDS1 --off \
--output HDMI1 --auto --primary \
--output VGA1 --auto --right-of HDMI1
elif [ -n "$HDMI1" -a -z "$VGA1" ]; then
echo "$prefix HDMI1 is plugged in, but not VGA1"
echo "$prefix SETTING: LVDS1 (Primary) - HDMI1 (Right)"
xrandr --output VGA1 --off \
--output LVDS1 --auto --primary \
--output HDMI1 --auto --right-of LVDS1 --noprimary
elif [ -z "$HDMI1" -a -n "$VGA1" ]; then
echo "$prefix SETTING: LVDS1 (Primary) - VGA1 (Right)"
xrandr --output HDMI1 --off \
--output LVDS1 --auto --primary \
--output VGA1 --auto --right-of LVDS1 --noprimary
if [ -n "$DP1" ]; then
echo "$prefix DP1 is plugged in, but not VGA1"
echo "$prefix SETTING: LVDS1 (Primary) - DP1 (Right)"
xrandr --output LVDS1 --auto --primary \
--output DP1 --auto --left-of LVDS1 --noprimary
else
echo "$prefix No external monitors are plugged in"
xrandr --output HDMI1 --off \
--output VGA1 --off \
xrandr --output DP1 --off \
--output LVDS1 --auto --primary
fi
}
Expand Down Expand Up @@ -209,5 +187,5 @@ trap "echo 'Received signal. Reconfiguring displays.' ; configure_displays" RTMI
while :
do
sleep 60 &
wait
wait
done