Skip to content

Instantly share code, notes, and snippets.

@primalmotion
Last active March 5, 2022 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save primalmotion/04705b4f26ff56288978a5b1ee2671fb to your computer and use it in GitHub Desktop.
Save primalmotion/04705b4f26ff56288978a5b1ee2671fb to your computer and use it in GitHub Desktop.
#!/bin/env bash
## add this to sway conf
# exec_always lid.sh
# bindswitch --reload --locked lid:toggle exec lid.sh
if grep -q open /proc/acpi/button/lid/LID0/state; then
swaymsg "output eDP-1 enable"
else
# If we are not in CLAMSHELL mode
if [[ "$(swaymsg -t get_outputs | grep -c name)" == "1" ]]; then
suspend.sh force
else
swaymsg "output eDP-1 disable"
fi
fi
#!/bin/env bash
# if swaylock is running, we're good
killall rofi
pgrep swaylock >/dev/null && exit 0
swaylock
sleep 2
#!/bin/bash
if grep -q open /proc/acpi/button/lid/LID0/state; then
swaymsg "output * enable"
else
swaymsg "output DP-1 enable"
fi
iwctl station wlan0 scan
#!/bin/bash
if [[ "$1" == "force" || ! $(playerctl -a status | grep 'Playing') && "$(pactl list source-outputs short | wc -l)" == "0" ]]; then
playerctl -a pause
systemctl suspend-then-hibernate
else
lockscreen.sh
swaymsg "output * disable"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment