Replace common functionality with rust implementation

This commit is contained in:
2025-09-03 17:06:13 +02:00
parent d0d162f3e9
commit d31d39473b
38 changed files with 2871 additions and 204 deletions

View File

@@ -1,2 +0,0 @@
#!/usr/bin/env bash
rofi -show combi -combi-modi run -display-combi "run"

View File

@@ -1,84 +0,0 @@
#!/bin/bash
### From http://www.archlinux.org/index.php/i3
_logfile="$XDG_RUNTIME_DIR/i3exit.log"
touch "$_logfile"
log()
{
echo "$*"
echo "[$(date +%FT%T)] $*" >> "$_logfile"
}
lock()
{
set -x
playerctl -p spotify pause
i3lock --nofork --show-failed-attempts --ignore-empty-password \
--color "000000"
}
screen_off() {
xset dpms force off
}
reset_screen() {
systemctl --user restart dpms.service
}
lock_and_screen_off() {
lock &
_pid=$!
dunst_paused=$(dunstctl is-paused)
[[ "${dunst_paused}" != "true" ]] && dunstctl set-paused true
screen_off
wait $_pid
[[ "${dunst_paused}" != "true" ]] && dunstctl set-paused false
reset_screen
}
signal="$1"
log "[I] Received signal \"$signal\"."
case "$signal" in
lock)
log "[I] Locking session."
lock_and_screen_off
;;
logout)
log "[I] Exiting i3."
i3-msg exit
;;
suspend)
log "[I] Suspending."
lock &
sleep 0.1
systemctl suspend
;;
hibernate)
log "[I] Hibernating."
sudo systemctl hibernate
;;
reboot)
log "[I] Rebooting."
systemctl reboot
;;
shutdown)
log "[I] Shutting down."
systemctl poweroff
;;
screen-off)
log "[I] Turning screen off."
screen_off
;;
*)
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
log "[E] Signal \"$signal\" unknown. Aborting."
exit 2
esac
log "[I] Done."
exit 0

View File

@@ -1,47 +0,0 @@
#!/usr/bin/env bash
_status_file="${XDG_RUNTIME_DIR}/presentation-mode-on"
is_on() {
[[ -e "${_status_file}" ]]
}
switch_on() {
touch "${_status_file}"
dunstctl set-paused true &
systemctl --user --no-block stop redshift.service
systemctl --user --no-block stop spotify.service
}
switch_off() {
rm -f "${_status_file}"
dunstctl set-paused false &
systemctl --user --no-block start redshift.service
systemctl --user --no-block start spotify.service
}
case "$1" in
status)
if is_on ; then
printf "on\n"
else
printf "off\n"
fi
;;
toggle)
if is_on ; then
switch_off
else
switch_on
fi
;;
off)
switch_off
;;
on)
switch_on
;;
esac

View File

@@ -1,19 +0,0 @@
#!/usr/bin/env bash
options=(
"lock"
"logout"
"suspend"
"hibernate"
"reboot"
"shutdown"
"screen-off")
i=1
output=$(
for option in "${options[@]}"; do
echo "($i) $option"
(( i++ ))
done | rofi -dmenu -p "action" -no-custom)
[[ "$output" ]] && "$(dirname "$0")"/i3exit "${output#(*) }"