power: optimize kernel timers, GPU devfreq, conky, and D-Bus monitors for battery life
This commit is contained in:
1 parent
5da053d8a5
commit
e42eb573ed
7 files changed
+900
-885
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
[logging]
|
||||||
|
level=ERR
|
||||||
|
|
||||||
|
[connection]
|
||||||
|
wifi.powersave=3
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# /etc/conf.d/modemmanager: config file for modemmanager
|
# /etc/conf.d/modemmanager: config file for modemmanager
|
||||||
|
|
||||||
# Enable quick suspend/resume hooks and debug mode (allows mmcli --command AT queries)
|
# Enable quick suspend/resume hooks with minimal logging to save power
|
||||||
modemmanager_opts="--test-quick-suspend-resume --debug"
|
modemmanager_opts="--test-quick-suspend-resume --log-level=ERR"
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Bananarchy kernel and runtime power management optimizations
|
||||||
|
|
||||||
|
# Disable fbcon cursor blinking (eliminates 5 Hz fb_flashcursor + drm_fb_helper_damage_work wakeups)
|
||||||
|
if [ -w /sys/class/graphics/fbcon/cursor_blink ]; then
|
||||||
|
echo 0 > /sys/class/graphics/fbcon/cursor_blink 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Reduce periodic VM stat shepherd and dirty writeback timer wakeups
|
||||||
|
{ echo 10 > /proc/sys/vm/stat_interval; } 2>/dev/null || true
|
||||||
|
{ echo 1500 > /proc/sys/vm/dirty_writeback_centisecs; } 2>/dev/null || true
|
||||||
|
{ echo 3000 > /proc/sys/vm/dirty_expire_centisecs; } 2>/dev/null || true
|
||||||
|
{ echo "1 4 1 4" > /proc/sys/kernel/printk; } 2>/dev/null || true
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ conky.config = {
|
|||||||
draw_shades = true,
|
draw_shades = true,
|
||||||
font = 'Fira Code:size=14:style=Regular',
|
font = 'Fira Code:size=14:style=Regular',
|
||||||
use_xft = true,
|
use_xft = true,
|
||||||
update_interval = 15,
|
update_interval = 30,
|
||||||
}
|
}
|
||||||
|
|
||||||
conky.text = [[${alignc}${font Fira Code:size=32:style=Regular}${time %H:%M}${font}
|
conky.text = [[${alignc}${font Fira Code:size=32:style=Regular}${time %H:%M}${font}
|
||||||
|
|||||||
@@ -67,78 +67,61 @@ mainloop() {
|
|||||||
while : ; do
|
while : ; do
|
||||||
uim_st="$(doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null || /usr/libexec/msm-modem-uim-selection status 2>/dev/null || true)"
|
uim_st="$(doas -n /usr/libexec/msm-modem-uim-selection status 2>/dev/null || /usr/libexec/msm-modem-uim-selection status 2>/dev/null || true)"
|
||||||
if printf "%s\n" "$uim_st" | grep -q "^DUAL_SIM_ACTIVE=1$"; then
|
if printf "%s\n" "$uim_st" | grep -q "^DUAL_SIM_ACTIVE=1$"; then
|
||||||
# Run the daemon as root whenever doas permits it. Only fall back to
|
|
||||||
# an unprivileged instance when doas is unavailable, not when the root
|
|
||||||
# daemon merely exited or was restarted (an unprivileged instance
|
|
||||||
# cannot keep the user's call log and call state files writable).
|
|
||||||
if doas -n /usr/libexec/msm-modem-uim-selection status >/dev/null 2>&1; then
|
if doas -n /usr/libexec/msm-modem-uim-selection status >/dev/null 2>&1; then
|
||||||
doas -n /usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
|
doas -n /usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
|
||||||
else
|
else
|
||||||
/usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
|
/usr/libexec/msm-modem-uim-selection dsds-daemon 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
sleep 5
|
||||||
|
else
|
||||||
|
sleep 30
|
||||||
fi
|
fi
|
||||||
sleep 5
|
|
||||||
done
|
done
|
||||||
) &
|
) &
|
||||||
|
|
||||||
# Monitor for incoming calls
|
# Monitor ModemManager signals using a single dbus-monitor connection
|
||||||
dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Voice',type='signal',member='CallAdded'" |
|
dbus-monitor --system \
|
||||||
while read -r line; do
|
"interface='org.freedesktop.ModemManager1.Modem.Voice',type='signal',member='CallAdded'" \
|
||||||
echo "$line" | grep -qE "^signal" && sxmo_modem.sh checkforincomingcalls
|
"interface='org.freedesktop.ModemManager1.Modem.Messaging',type='signal',member='Added'" \
|
||||||
done &
|
"interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Sms'" \
|
||||||
|
"interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Call'" \
|
||||||
# Monitor for incoming texts
|
"interface='org.freedesktop.ModemManager1.Modem',type='signal',member='StateChanged'" \
|
||||||
dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem.Messaging',type='signal',member='Added'" |
|
"interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd'" |
|
||||||
while read -r line; do
|
|
||||||
echo "$line" | grep -qE "^signal" && sxmo_modem.sh checkfornewtexts
|
|
||||||
done &
|
|
||||||
|
|
||||||
# Monitor for finished calls
|
|
||||||
dbus-monitor --system "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Call'" |
|
|
||||||
while read -r line; do
|
|
||||||
echo "$line" | grep -qE "^signal" && sxmo_modem.sh checkforfinishedcalls
|
|
||||||
done &
|
|
||||||
|
|
||||||
# Monitor for modem state change
|
|
||||||
dbus-monitor --system "interface='org.freedesktop.ModemManager1.Modem',type='signal',member='StateChanged'" |
|
|
||||||
while read -r line; do
|
|
||||||
if echo "$line" | grep -qE "^signal.*StateChanged"; then
|
|
||||||
read -r oldstate
|
|
||||||
read -r newstate
|
|
||||||
read -r reason
|
|
||||||
sxmo_hook_modem.sh "$(statenumtoname "$oldstate")" \
|
|
||||||
"$(statenumtoname "$newstate")" \
|
|
||||||
"$(echo "$reason" | sed 's/uint32 //')"
|
|
||||||
sxmo_hook_statusbar.sh modem
|
|
||||||
fi
|
|
||||||
done &
|
|
||||||
|
|
||||||
# Monitor for 3GPP USSD
|
|
||||||
dbus-monitor --system "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.freedesktop.ModemManager1.Modem.Modem3gpp.Ussd'" |
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
case "$line" in
|
case "$line" in
|
||||||
*"/org/freedesktop/ModemManager1/Modem"*)
|
signal*"interface=org.freedesktop.ModemManager1.Modem.Voice"*"member=CallAdded"*)
|
||||||
MODEM=$(echo "$line" | awk -F'[;=]' '{print $6}')
|
sxmo_modem.sh checkforincomingcalls &
|
||||||
CHANGED=0
|
|
||||||
;;
|
;;
|
||||||
*"string \"NetworkNotification"*)
|
signal*"interface=org.freedesktop.ModemManager1.Modem.Messaging"*"member=Added"*)
|
||||||
TYPE="NetworkNotification"
|
sxmo_modem.sh checkfornewtexts &
|
||||||
CHANGED=1
|
|
||||||
;;
|
;;
|
||||||
*"string \"NetworkRequest"*)
|
signal*"path=/org/freedesktop/ModemManager1/SMS/"*"member=PropertiesChanged"*)
|
||||||
TYPE="NetworkRequest"
|
sxmo_modem.sh checkfornewtexts &
|
||||||
CHANGED=1
|
|
||||||
;;
|
;;
|
||||||
*)
|
signal*"path=/org/freedesktop/ModemManager1/Call/"*"member=PropertiesChanged"*)
|
||||||
CHANGED=0
|
sxmo_modem.sh checkforfinishedcalls &
|
||||||
|
;;
|
||||||
|
signal*"interface=org.freedesktop.ModemManager1.Modem;"*"member=StateChanged"*)
|
||||||
|
read -r oldstate || true
|
||||||
|
read -r newstate || true
|
||||||
|
read -r reason || true
|
||||||
|
(
|
||||||
|
sxmo_hook_modem.sh "$(statenumtoname "$oldstate")" \
|
||||||
|
"$(statenumtoname "$newstate")" \
|
||||||
|
"$(echo "$reason" | sed 's/uint32 //')"
|
||||||
|
sxmo_hook_statusbar.sh modem
|
||||||
|
) &
|
||||||
|
;;
|
||||||
|
signal*"path=/org/freedesktop/ModemManager1/Modem/"*"member=PropertiesChanged"*)
|
||||||
|
MODEM="$(echo "$line" | awk -F'[;=]' '{print $6}')"
|
||||||
|
;;
|
||||||
|
*"string \"NetworkNotification\""*)
|
||||||
|
[ -n "${MODEM:-}" ] && sxmo_ussd.sh "$MODEM" "NetworkNotification" "" &
|
||||||
|
;;
|
||||||
|
*"string \"NetworkRequest\""*)
|
||||||
|
[ -n "${MODEM:-}" ] && sxmo_ussd.sh "$MODEM" "NetworkRequest" "" &
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "$CHANGED" = "1" ]; then
|
|
||||||
# Handle unsolicited USSD in background without spawning a terminal window
|
|
||||||
sxmo_ussd.sh "$MODEM" "$TYPE" "" &
|
|
||||||
fi
|
|
||||||
|
|
||||||
done &
|
done &
|
||||||
|
|
||||||
if [ -f "${SXMO_MMS_BASE_DIR:-"$HOME"/.mms/modemmanager}/mms" ]; then
|
if [ -f "${SXMO_MMS_BASE_DIR:-"$HOME"/.mms/modemmanager}/mms" ]; then
|
||||||
|
|||||||
+362
-362
@@ -11,566 +11,566 @@ export DISPLAY="${DISPLAY:-:0}"
|
|||||||
export SXMO_WM="${SXMO_WM:-dwm}"
|
export SXMO_WM="${SXMO_WM:-dwm}"
|
||||||
|
|
||||||
_dwm_prep() {
|
_dwm_prep() {
|
||||||
if [ -z "$DISPLAY" ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
export DISPLAY=:0
|
export DISPLAY=:0
|
||||||
fi
|
fi
|
||||||
if [ -e /tmp/dwm_plugin_dmenu.active ] && [ -p /tmp/dwm_plugin_dmenu.fifo ]; then
|
if [ -e /tmp/dwm_plugin_dmenu.active ] && [ -p /tmp/dwm_plugin_dmenu.fifo ]; then
|
||||||
printf "CLOSE\n" > /tmp/dwm_plugin_dmenu.fifo 2>/dev/null || true
|
printf "CLOSE\n" > /tmp/dwm_plugin_dmenu.fifo 2>/dev/null || true
|
||||||
sleep 0.04
|
sleep 0.04
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
swi3msg() {
|
swi3msg() {
|
||||||
case "$SXMO_WM" in
|
case "$SXMO_WM" in
|
||||||
sway) swaymsg "$@" ;;
|
sway) swaymsg "$@" ;;
|
||||||
i3) i3-msg "$@" ;;
|
i3) i3-msg "$@" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output Power Management {{{
|
# Output Power Management {{{
|
||||||
xorgdisplay() {
|
xorgdisplay() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
off)
|
off)
|
||||||
if [ -r /sys/class/backlight/backlight/brightness ]; then
|
if [ -r /sys/class/backlight/backlight/brightness ]; then
|
||||||
_cur_bl=0
|
_cur_bl=0
|
||||||
read -r _cur_bl < /sys/class/backlight/backlight/brightness 2>/dev/null || true
|
read -r _cur_bl < /sys/class/backlight/backlight/brightness 2>/dev/null || true
|
||||||
if [ "${_cur_bl:-0}" -ge 1 ] 2>/dev/null; then
|
if [ "${_cur_bl:-0}" -ge 1 ] 2>/dev/null; then
|
||||||
printf '%s\n' "$_cur_bl" > /tmp/sxmo_saved_brightness 2>/dev/null || true
|
printf '%s\n' "$_cur_bl" > /tmp/sxmo_saved_brightness 2>/dev/null || true
|
||||||
mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo" 2>/dev/null || true
|
mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo" 2>/dev/null || true
|
||||||
printf '%s\n' "$_cur_bl" > "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" 2>/dev/null || true
|
printf '%s\n' "$_cur_bl" > "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then
|
if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then
|
||||||
printf '0\n' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true
|
printf '0\n' > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
if [ -w /sys/class/backlight/backlight/brightness ]; then
|
if [ -w /sys/class/backlight/backlight/brightness ]; then
|
||||||
printf '0\n' > /sys/class/backlight/backlight/brightness 2>/dev/null || true
|
printf '0\n' > /sys/class/backlight/backlight/brightness 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
xset s off s noblank >/dev/null 2>&1 || true
|
xset s off s noblank >/dev/null 2>&1 || true
|
||||||
;;
|
;;
|
||||||
on)
|
on)
|
||||||
xset s off s noblank >/dev/null 2>&1 || true
|
xset s off s noblank >/dev/null 2>&1 || true
|
||||||
if [ -w /sys/class/backlight/backlight/bl_power ]; then
|
if [ -w /sys/class/backlight/backlight/bl_power ]; then
|
||||||
printf '0\n' > /sys/class/backlight/backlight/bl_power 2>/dev/null || true
|
printf '0\n' > /sys/class/backlight/backlight/bl_power 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
if [ -w /sys/class/backlight/backlight/brightness ]; then
|
if [ -w /sys/class/backlight/backlight/brightness ]; then
|
||||||
_restore_bl=""
|
_restore_bl=""
|
||||||
if [ -r /tmp/sxmo_saved_brightness ]; then
|
if [ -r /tmp/sxmo_saved_brightness ]; then
|
||||||
read -r _restore_bl < /tmp/sxmo_saved_brightness 2>/dev/null || true
|
read -r _restore_bl < /tmp/sxmo_saved_brightness 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
if [ -z "$_restore_bl" ] || [ "${_restore_bl:-0}" -lt 1 ] 2>/dev/null; then
|
if [ -z "$_restore_bl" ] || [ "${_restore_bl:-0}" -lt 1 ] 2>/dev/null; then
|
||||||
if [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" ]; then
|
if [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" ]; then
|
||||||
read -r _restore_bl < "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" 2>/dev/null || true
|
read -r _restore_bl < "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/brightness" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -z "$_restore_bl" ] || [ "${_restore_bl:-0}" -lt 1 ] 2>/dev/null; then
|
if [ -z "$_restore_bl" ] || [ "${_restore_bl:-0}" -lt 1 ] 2>/dev/null; then
|
||||||
_restore_bl=14
|
_restore_bl=14
|
||||||
read -r _restore_bl < /sys/class/backlight/backlight/max_brightness 2>/dev/null || true
|
read -r _restore_bl < /sys/class/backlight/backlight/max_brightness 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
printf '%s\n' "${_restore_bl:-14}" > /tmp/sxmo_saved_brightness 2>/dev/null || true
|
printf '%s\n' "${_restore_bl:-14}" > /tmp/sxmo_saved_brightness 2>/dev/null || true
|
||||||
printf '%s\n' "${_restore_bl:-14}" > /sys/class/backlight/backlight/brightness 2>/dev/null || true
|
printf '%s\n' "${_restore_bl:-14}" > /sys/class/backlight/backlight/brightness 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then
|
if [ -w /sys/class/leds/white:kbd_backlight/brightness ]; then
|
||||||
_restore_kbd="255"
|
_restore_kbd="255"
|
||||||
if [ -r /tmp/sxmo_saved_kbd_brightness ]; then
|
if [ -r /tmp/sxmo_saved_kbd_brightness ]; then
|
||||||
read -r _restore_kbd < /tmp/sxmo_saved_kbd_brightness 2>/dev/null || true
|
read -r _restore_kbd < /tmp/sxmo_saved_kbd_brightness 2>/dev/null || true
|
||||||
elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/kbd_brightness" ]; then
|
elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/kbd_brightness" ]; then
|
||||||
read -r _restore_kbd < "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/kbd_brightness" 2>/dev/null || true
|
read -r _restore_kbd < "${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/kbd_brightness" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
printf '%s\n' "${_restore_kbd:-255}" > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true
|
printf '%s\n' "${_restore_kbd:-255}" > /sys/class/leds/white:kbd_backlight/brightness 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
_cur_bl=14
|
_cur_bl=14
|
||||||
if [ -r /sys/class/backlight/backlight/brightness ]; then
|
if [ -r /sys/class/backlight/backlight/brightness ]; then
|
||||||
read -r _cur_bl < /sys/class/backlight/backlight/brightness 2>/dev/null || _cur_bl=14
|
read -r _cur_bl < /sys/class/backlight/backlight/brightness 2>/dev/null || _cur_bl=14
|
||||||
fi
|
fi
|
||||||
if [ "${_cur_bl:-0}" -le 0 ] 2>/dev/null; then
|
if [ "${_cur_bl:-0}" -le 0 ] 2>/dev/null; then
|
||||||
printf "off\n"
|
printf "off\n"
|
||||||
else
|
else
|
||||||
printf "on\n"
|
printf "on\n"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf 'sxmo_wm.sh display: unknown command "%s"\n' "$1" >&2
|
printf 'sxmo_wm.sh display: unknown command "%s"\n' "$1" >&2
|
||||||
printf 'Usage: sxmo_wm.sh display [on|off]\n' >&2
|
printf 'Usage: sxmo_wm.sh display [on|off]\n' >&2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
wldisplay() {
|
wldisplay() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
on) wlopm --on "*" ;;
|
on) wlopm --on "*" ;;
|
||||||
off) wlopm --off "*";;
|
off) wlopm --off "*";;
|
||||||
"")
|
"")
|
||||||
if wlopm | grep -q "on"; then
|
if wlopm | grep -q "on"; then
|
||||||
printf "on\n"
|
printf "on\n"
|
||||||
else
|
else
|
||||||
printf "off\n"
|
printf "off\n"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf 'sxmo_wm.sh display: unknown command "%s"\n' "$1" >&2
|
printf 'sxmo_wm.sh display: unknown command "%s"\n' "$1" >&2
|
||||||
printf 'Usage: sxmo_wm.sh display [on|off]\n' >&2
|
printf 'Usage: sxmo_wm.sh display [on|off]\n' >&2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
wm_generic_dpms() {
|
wm_generic_dpms() {
|
||||||
sxmo_log "WARNING: $0: the dpms subcommand is deprecated, use display instead"
|
sxmo_log "WARNING: $0: the dpms subcommand is deprecated, use display instead"
|
||||||
|
|
||||||
# The dpms command was origionally implemented with on/off being the
|
# The dpms command was origionally implemented with on/off being the
|
||||||
# opposite of what they should have been. Swap them for backwards
|
# opposite of what they should have been. Swap them for backwards
|
||||||
# compatability.
|
# compatability.
|
||||||
case "$1" in
|
case "$1" in
|
||||||
on)
|
on)
|
||||||
shift
|
shift
|
||||||
set -- "off" "$@"
|
set -- "off" "$@"
|
||||||
;;
|
;;
|
||||||
off)
|
off)
|
||||||
shift
|
shift
|
||||||
set -- "on" "$@"
|
set -- "on" "$@"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
dispatch display "$@"
|
dispatch display "$@"
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# inputevent {{{
|
# inputevent {{{
|
||||||
xorginputevent() {
|
xorginputevent() {
|
||||||
if [ "$1" = "touchscreen" ]; then
|
if [ "$1" = "touchscreen" ]; then
|
||||||
TOUCH_POINTER_ID="$SXMO_TOUCHSCREEN_ID"
|
TOUCH_POINTER_ID="$SXMO_TOUCHSCREEN_ID"
|
||||||
elif [ "$1" = "stylus" ]; then
|
elif [ "$1" = "stylus" ]; then
|
||||||
TOUCH_POINTER_ID="$SXMO_STYLUS_ID"
|
TOUCH_POINTER_ID="$SXMO_STYLUS_ID"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$TOUCH_POINTER_ID" ]; then
|
if [ -z "$TOUCH_POINTER_ID" ]; then
|
||||||
echo "not found"
|
echo "not found"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
STATE=off
|
STATE=off
|
||||||
if xinput list-props "$TOUCH_POINTER_ID" | \
|
if xinput list-props "$TOUCH_POINTER_ID" | \
|
||||||
grep "Device Enabled" | \
|
grep "Device Enabled" | \
|
||||||
grep -q "1$"; then
|
grep -q "1$"; then
|
||||||
STATE=on
|
STATE=on
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
printf %s "$STATE"
|
printf %s "$STATE"
|
||||||
elif [ "$2" = on ] && [ "$STATE" != on ]; then
|
elif [ "$2" = on ] && [ "$STATE" != on ]; then
|
||||||
xinput enable "$TOUCH_POINTER_ID"
|
xinput enable "$TOUCH_POINTER_ID"
|
||||||
elif [ "$2" = off ] && [ "$STATE" != off ] ; then
|
elif [ "$2" = off ] && [ "$STATE" != off ] ; then
|
||||||
xinput disable "$TOUCH_POINTER_ID"
|
xinput disable "$TOUCH_POINTER_ID"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
swayinputevent() {
|
swayinputevent() {
|
||||||
if [ "$1" = "touchscreen" ]; then
|
if [ "$1" = "touchscreen" ]; then
|
||||||
TOUCH_POINTER_ID="touch"
|
TOUCH_POINTER_ID="touch"
|
||||||
elif [ "$1" = "stylus" ]; then
|
elif [ "$1" = "stylus" ]; then
|
||||||
TOUCH_POINTER_ID="tablet_tool"
|
TOUCH_POINTER_ID="tablet_tool"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we dont have any matching input
|
# If we dont have any matching input
|
||||||
if ! swaymsg -t get_inputs \
|
if ! swaymsg -t get_inputs \
|
||||||
| jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" )" \
|
| jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" )" \
|
||||||
| grep -q .; then
|
| grep -q .; then
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
printf "not found"
|
printf "not found"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
STATE=on
|
STATE=on
|
||||||
if swaymsg -t get_inputs \
|
if swaymsg -t get_inputs \
|
||||||
| jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" ) | .libinput.send_events" \
|
| jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" ) | .libinput.send_events" \
|
||||||
| grep -q "disabled"; then
|
| grep -q "disabled"; then
|
||||||
STATE=off
|
STATE=off
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
printf %s "$STATE"
|
printf %s "$STATE"
|
||||||
elif [ "$2" = on ] && [ "$STATE" != on ]; then
|
elif [ "$2" = on ] && [ "$STATE" != on ]; then
|
||||||
swaymsg "input type:$TOUCH_POINTER_ID events enabled" > /dev/null
|
swaymsg "input type:$TOUCH_POINTER_ID events enabled" > /dev/null
|
||||||
elif [ "$2" = off ] && [ "$STATE" != off ] ; then
|
elif [ "$2" = off ] && [ "$STATE" != off ] ; then
|
||||||
swaymsg "input type:$TOUCH_POINTER_ID events disabled" > /dev/null
|
swaymsg "input type:$TOUCH_POINTER_ID events disabled" > /dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# focusedwindow {{{
|
# focusedwindow {{{
|
||||||
_xorgfocusedwindow() {
|
_xorgfocusedwindow() {
|
||||||
xprop -id "$(xdotool getactivewindow 2>/dev/null)" 2>/dev/null | awk '
|
xprop -id "$(xdotool getactivewindow 2>/dev/null)" 2>/dev/null | awk '
|
||||||
/^WM_CLASS/ {
|
/^WM_CLASS/ {
|
||||||
sub(/^WM_CLASS[^=]*= ?"[^"]*", "/, "")
|
sub(/^WM_CLASS[^=]*= ?"[^"]*", "/, "")
|
||||||
sub(/"$/, "")
|
sub(/"$/, "")
|
||||||
class = $0
|
class = $0
|
||||||
}
|
}
|
||||||
/^WM_NAME/ {
|
/^WM_NAME/ {
|
||||||
sub(/^WM_NAME[^=]*= ?"/, "")
|
sub(/^WM_NAME[^=]*= ?"/, "")
|
||||||
sub(/"$/, "")
|
sub(/"$/, "")
|
||||||
title = $0
|
title = $0
|
||||||
}
|
}
|
||||||
END { printf "%s\n%s\n", tolower(class), tolower(title) }
|
END { printf "%s\n%s\n", tolower(class), tolower(title) }
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
_swi3_focusedwindow() {
|
_swi3_focusedwindow() {
|
||||||
swi3msg -t get_tree | jq -r '
|
swi3msg -t get_tree | jq -r '
|
||||||
recurse(.nodes[]) |
|
recurse(.nodes[]) |
|
||||||
select(.focused == true) |
|
select(.focused == true) |
|
||||||
{
|
{
|
||||||
app_id: ((if .app_id != null then
|
app_id: ((if .app_id != null then
|
||||||
.app_id
|
.app_id
|
||||||
else
|
else
|
||||||
.window_properties.class
|
.window_properties.class
|
||||||
end) // "" | tostring | gsub("\n"; "\\n") | ascii_downcase),
|
end) // "" | tostring | gsub("\n"; "\\n") | ascii_downcase),
|
||||||
name: ((.name // "") | tostring | gsub("\n"; "\\n") | ascii_downcase),
|
name: ((.name // "") | tostring | gsub("\n"; "\\n") | ascii_downcase),
|
||||||
} |
|
} |
|
||||||
select(.app_id != "" or .name != "") |
|
select(.app_id != "" or .name != "") |
|
||||||
"\(.app_id)\n\(.name)"
|
"\(.app_id)\n\(.name)"
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
_raw_focusedwindow() {
|
_raw_focusedwindow() {
|
||||||
case "$SXMO_WM" in
|
case "$SXMO_WM" in
|
||||||
dwm) _xorgfocusedwindow ;;
|
dwm) _xorgfocusedwindow ;;
|
||||||
sway|i3) _swi3_focusedwindow ;;
|
sway|i3) _swi3_focusedwindow ;;
|
||||||
river) lswt -j | jq -r '
|
river) lswt -j | jq -r '
|
||||||
.toplevels |
|
.toplevels |
|
||||||
map(select(.activated))[0] |
|
map(select(.activated))[0] |
|
||||||
(."app-id" | ascii_downcase), (.title | ascii_downcase)
|
(."app-id" | ascii_downcase), (.title | ascii_downcase)
|
||||||
'
|
'
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
wm_generic_focusedwindow() {
|
wm_generic_focusedwindow() {
|
||||||
if [ "$1" = "-r" ]; then
|
if [ "$1" = "-r" ]; then
|
||||||
_raw_focusedwindow
|
_raw_focusedwindow
|
||||||
else
|
else
|
||||||
# This script originally output this format, which is a bit
|
# This script originally output this format, which is a bit
|
||||||
# harder to parse. Keep it for backwards compatibility in case
|
# harder to parse. Keep it for backwards compatibility in case
|
||||||
# anyone was using it.
|
# anyone was using it.
|
||||||
_raw_focusedwindow | {
|
_raw_focusedwindow | {
|
||||||
read -r app
|
read -r app
|
||||||
read -r title
|
read -r title
|
||||||
printf "app: %s\ntitle: %s\n" "$app" "$title"
|
printf "app: %s\ntitle: %s\n" "$app" "$title"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# paste {{{
|
# paste {{{
|
||||||
wlpaste() {
|
wlpaste() {
|
||||||
wl-paste
|
wl-paste
|
||||||
}
|
}
|
||||||
|
|
||||||
xorgpaste() {
|
xorgpaste() {
|
||||||
xclip -o
|
xclip -o
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# exec {{{
|
# exec {{{
|
||||||
wm_generic__swi3exec_inner() {
|
wm_generic__swi3exec_inner() {
|
||||||
cmd="$(cat "$1")"
|
cmd="$(cat "$1")"
|
||||||
rm "$1"
|
rm "$1"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
}
|
}
|
||||||
|
|
||||||
swi3exec() {
|
swi3exec() {
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
cmdfile="$(mktemp)"
|
cmdfile="$(mktemp)"
|
||||||
jq -r --null-input '$ARGS.positional | @sh' --args -- "$@" > "$cmdfile"
|
jq -r --null-input '$ARGS.positional | @sh' --args -- "$@" > "$cmdfile"
|
||||||
|
|
||||||
swi3msg exec "sxmo_wm.sh _swi3exec_inner '$cmdfile'" > /dev/null
|
swi3msg exec "sxmo_wm.sh _swi3exec_inner '$cmdfile'" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
riverexec() {
|
riverexec() {
|
||||||
riverctl spawn "$@"
|
riverctl spawn "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
xorgexec() {
|
xorgexec() {
|
||||||
if [ -z "$DISPLAY" ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
export DISPLAY=:0
|
export DISPLAY=:0
|
||||||
fi
|
fi
|
||||||
"$@" &
|
"$@" &
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# execwait {{{
|
# execwait {{{
|
||||||
wm_generic__execwait_inner() {
|
wm_generic__execwait_inner() {
|
||||||
notify_file="$1/done"
|
notify_file="$1/done"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# This opens the pipe for writing, when this process exits it will be
|
# This opens the pipe for writing, when this process exits it will be
|
||||||
# closed, which will send eof to the monitoring process.
|
# closed, which will send eof to the monitoring process.
|
||||||
exec 3>"$notify_file"
|
exec 3>"$notify_file"
|
||||||
|
|
||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_execwait() {
|
_execwait() {
|
||||||
set -e
|
set -e
|
||||||
runner="$1"
|
runner="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
notify_dir="$(mktemp -d)"
|
notify_dir="$(mktemp -d)"
|
||||||
mkfifo "$notify_dir/done"
|
mkfifo "$notify_dir/done"
|
||||||
|
|
||||||
"$runner" sxmo_wm.sh _execwait_inner "$notify_dir" "$@"
|
"$runner" sxmo_wm.sh _execwait_inner "$notify_dir" "$@"
|
||||||
|
|
||||||
exec 3<"$notify_dir/done"
|
exec 3<"$notify_dir/done"
|
||||||
|
|
||||||
# The exec line won't finish until the inner file has been opened for
|
# The exec line won't finish until the inner file has been opened for
|
||||||
# writing, so it's safe to remove the temp dir here.
|
# writing, so it's safe to remove the temp dir here.
|
||||||
rm -r "$notify_dir"
|
rm -r "$notify_dir"
|
||||||
|
|
||||||
# Wait for the notification file to be closed
|
# Wait for the notification file to be closed
|
||||||
read -r _ <&3 || true
|
read -r _ <&3 || true
|
||||||
}
|
}
|
||||||
|
|
||||||
swi3execwait() {
|
swi3execwait() {
|
||||||
_execwait swi3exec "$@"
|
_execwait swi3exec "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
riverexecwait() {
|
riverexecwait() {
|
||||||
_execwait riverexec "$@"
|
_execwait riverexec "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
xorgexecwait() {
|
xorgexecwait() {
|
||||||
if [ -z "$DISPLAY" ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
export DISPLAY=:0
|
export DISPLAY=:0
|
||||||
fi
|
fi
|
||||||
exec "$@"
|
exec "$@"
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# toggle layout {{{
|
# toggle layout {{{
|
||||||
swi3togglelayout() {
|
swi3togglelayout() {
|
||||||
swi3msg "layout toggle splitv splith tabbed" > /dev/null
|
swi3msg "layout toggle splitv splith tabbed" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
dwmtogglelayout() {
|
dwmtogglelayout() {
|
||||||
_dwm_prep
|
_dwm_prep
|
||||||
xdotool key --clearmodifiers Super+space
|
xdotool key --clearmodifiers Super+space
|
||||||
}
|
}
|
||||||
|
|
||||||
rivertogglelayout() {
|
rivertogglelayout() {
|
||||||
riverctl toggle-fullscreen
|
riverctl toggle-fullscreen
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# switch focus {{{
|
# switch focus {{{
|
||||||
i3switchfocus() {
|
i3switchfocus() {
|
||||||
sxmo_wmmenu.sh i3windowswitcher
|
sxmo_wmmenu.sh i3windowswitcher
|
||||||
}
|
}
|
||||||
|
|
||||||
swayswitchfocus() {
|
swayswitchfocus() {
|
||||||
sxmo_wmmenu.sh swaywindowswitcher
|
sxmo_wmmenu.sh swaywindowswitcher
|
||||||
}
|
}
|
||||||
|
|
||||||
dwmswitchfocus() {
|
dwmswitchfocus() {
|
||||||
_dwm_prep
|
_dwm_prep
|
||||||
xdotool key --clearmodifiers Super+x
|
xdotool key --clearmodifiers Super+x
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# workspace switching {{{
|
# workspace switching {{{
|
||||||
_swi3getcurrentworkspace() {
|
_swi3getcurrentworkspace() {
|
||||||
swi3msg -t get_workspaces | jq -r '.[] | select(.focused).name'
|
swi3msg -t get_workspaces | jq -r '.[] | select(.focused).name'
|
||||||
}
|
}
|
||||||
|
|
||||||
_swi3getnextworkspace() {
|
_swi3getnextworkspace() {
|
||||||
value="$(($(_swi3getcurrentworkspace)+1))"
|
value="$(($(_swi3getcurrentworkspace)+1))"
|
||||||
if [ "$value" -eq "$((${SXMO_WORKSPACE_WRAPPING:-4}+1))" ]; then
|
if [ "$value" -eq "$((${SXMO_WORKSPACE_WRAPPING:-4}+1))" ]; then
|
||||||
printf 1
|
printf 1
|
||||||
else
|
else
|
||||||
printf %s "$value"
|
printf %s "$value"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_swi3getpreviousworkspace() {
|
_swi3getpreviousworkspace() {
|
||||||
value="$(($(_swi3getcurrentworkspace)-1))"
|
value="$(($(_swi3getcurrentworkspace)-1))"
|
||||||
if [ "$value" -lt 1 ]; then
|
if [ "$value" -lt 1 ]; then
|
||||||
if [ "${SXMO_WORKSPACE_WRAPPING:-4}" -ne 0 ]; then
|
if [ "${SXMO_WORKSPACE_WRAPPING:-4}" -ne 0 ]; then
|
||||||
printf %s "${SXMO_WORKSPACE_WRAPPING:-4}"
|
printf %s "${SXMO_WORKSPACE_WRAPPING:-4}"
|
||||||
else
|
else
|
||||||
return 1 # cant have previous workspace
|
return 1 # cant have previous workspace
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printf %s "$value"
|
printf %s "$value"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
swi3nextworkspace() {
|
swi3nextworkspace() {
|
||||||
swi3msg "workspace $(_swi3getnextworkspace)" > /dev/null
|
swi3msg "workspace $(_swi3getnextworkspace)" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
rivernextworkspace() {
|
rivernextworkspace() {
|
||||||
river-shifttags
|
river-shifttags
|
||||||
}
|
}
|
||||||
|
|
||||||
dwmnextworkspace() {
|
dwmnextworkspace() {
|
||||||
_dwm_prep
|
_dwm_prep
|
||||||
xdotool key --clearmodifiers Super+Shift+r
|
xdotool key --clearmodifiers Super+Shift+r
|
||||||
}
|
}
|
||||||
|
|
||||||
swi3previousworkspace() {
|
swi3previousworkspace() {
|
||||||
swi3msg "workspace $(_swi3getpreviousworkspace )" > /dev/null
|
swi3msg "workspace $(_swi3getpreviousworkspace )" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
dwmpreviousworkspace() {
|
dwmpreviousworkspace() {
|
||||||
_dwm_prep
|
_dwm_prep
|
||||||
xdotool key --clearmodifiers Super+Shift+e
|
xdotool key --clearmodifiers Super+Shift+e
|
||||||
}
|
}
|
||||||
|
|
||||||
riverpreviousworkspace() {
|
riverpreviousworkspace() {
|
||||||
river-shifttags --shift -1
|
river-shifttags --shift -1
|
||||||
}
|
}
|
||||||
|
|
||||||
swi3movenextworkspace() {
|
swi3movenextworkspace() {
|
||||||
swi3msg "move container to workspace $(_swi3getnextworkspace)" > /dev/null
|
swi3msg "move container to workspace $(_swi3getnextworkspace)" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
dwmmovenextworkspace() {
|
dwmmovenextworkspace() {
|
||||||
_dwm_prep
|
_dwm_prep
|
||||||
xdotool key --clearmodifiers Super+r
|
xdotool key --clearmodifiers Super+r
|
||||||
}
|
}
|
||||||
|
|
||||||
swi3movepreviousworkspace() {
|
swi3movepreviousworkspace() {
|
||||||
swi3msg "move container to workspace $(_swi3getpreviousworkspace )" > /dev/null
|
swi3msg "move container to workspace $(_swi3getpreviousworkspace )" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
dwmmovepreviousworkspace() {
|
dwmmovepreviousworkspace() {
|
||||||
_dwm_prep
|
_dwm_prep
|
||||||
xdotool key --clearmodifiers Super+e
|
xdotool key --clearmodifiers Super+e
|
||||||
}
|
}
|
||||||
|
|
||||||
swi3workspace() {
|
swi3workspace() {
|
||||||
swi3msg "workspace $1" > /dev/null
|
swi3msg "workspace $1" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
riverworkspace() {
|
riverworkspace() {
|
||||||
tags=$((1 << ($1 - 1)))
|
tags=$((1 << ($1 - 1)))
|
||||||
riverctl set-focused-tags "$tags"
|
riverctl set-focused-tags "$tags"
|
||||||
}
|
}
|
||||||
|
|
||||||
dwmworkspace() {
|
dwmworkspace() {
|
||||||
_dwm_prep
|
_dwm_prep
|
||||||
xdotool key --clearmodifiers "Super+$1"
|
xdotool key --clearmodifiers "Super+$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
swi3moveworkspace() {
|
swi3moveworkspace() {
|
||||||
swi3msg "move container to workspace $1" > /dev/null
|
swi3msg "move container to workspace $1" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
rivermoveworkspace() {
|
rivermoveworkspace() {
|
||||||
tags=$((1 << ($1 - 1)))
|
tags=$((1 << ($1 - 1)))
|
||||||
riverctl set-view-tags "$tags"
|
riverctl set-view-tags "$tags"
|
||||||
}
|
}
|
||||||
|
|
||||||
dwmmoveworkspace() {
|
dwmmoveworkspace() {
|
||||||
_dwm_prep
|
_dwm_prep
|
||||||
xdotool key --clearmodifiers "Super+shift+$1"
|
xdotool key --clearmodifiers "Super+shift+$1"
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# toggle bar {{{
|
# toggle bar {{{
|
||||||
swi3togglebar() {
|
swi3togglebar() {
|
||||||
swi3msg "bar mode toggle" > /dev/null
|
swi3msg "bar mode toggle" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
dwmtogglebar() {
|
dwmtogglebar() {
|
||||||
if [ -z "$DISPLAY" ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
export DISPLAY=:0
|
export DISPLAY=:0
|
||||||
fi
|
fi
|
||||||
xdotool key --clearmodifiers "Super+b"
|
xdotool key --clearmodifiers "Super+b"
|
||||||
}
|
}
|
||||||
|
|
||||||
rivertogglebar() {
|
rivertogglebar() {
|
||||||
if superctl status sxmo_riverbar | grep -q started; then
|
if superctl status sxmo_riverbar | grep -q started; then
|
||||||
superctl stop sxmo_riverbar
|
superctl stop sxmo_riverbar
|
||||||
else
|
else
|
||||||
superctl start sxmo_riverbar
|
superctl start sxmo_riverbar
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# configmenuentry {{{
|
# configmenuentry {{{
|
||||||
wm_generic_configmenuentry() {
|
wm_generic_configmenuentry() {
|
||||||
# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh
|
# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh
|
||||||
. sxmo_hook_icons.sh
|
. sxmo_hook_icons.sh
|
||||||
case "$SXMO_WM" in
|
case "$SXMO_WM" in
|
||||||
dwm)
|
dwm)
|
||||||
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/xinit"
|
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/xinit"
|
||||||
;;
|
;;
|
||||||
i3)
|
i3)
|
||||||
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/i3"
|
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/i3"
|
||||||
;;
|
;;
|
||||||
river)
|
river)
|
||||||
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/river"
|
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/river"
|
||||||
;;
|
;;
|
||||||
sway)
|
sway)
|
||||||
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/sway"
|
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/sway"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
dispatch() {
|
dispatch() {
|
||||||
if [ "$#" -lt 1 ]; then
|
if [ "$#" -lt 1 ]; then
|
||||||
echo "Usage: sxmo_wm.sh <command>" >&2
|
echo "Usage: sxmo_wm.sh <command>" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
action="$1"
|
action="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# invoke action covering single wm
|
# invoke action covering single wm
|
||||||
if type "$SXMO_WM$action" >/dev/null 2>&1; then
|
if type "$SXMO_WM$action" >/dev/null 2>&1; then
|
||||||
"$SXMO_WM$action" "$@"
|
"$SXMO_WM$action" "$@"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# invoke action covering multiple wms
|
# invoke action covering multiple wms
|
||||||
if [ "$SXMO_WM" = "sway" ] || [ "$SXMO_WM" = "i3" ]; then
|
if [ "$SXMO_WM" = "sway" ] || [ "$SXMO_WM" = "i3" ]; then
|
||||||
if type "swi3$action" >/dev/null 2>&1; then
|
if type "swi3$action" >/dev/null 2>&1; then
|
||||||
"swi3$action" "$@"
|
"swi3$action" "$@"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# invoke action covering all of xorg/wayland
|
# invoke action covering all of xorg/wayland
|
||||||
case "$SXMO_WM" in
|
case "$SXMO_WM" in
|
||||||
dwm|i3)
|
dwm|i3)
|
||||||
if type "xorg$action" >/dev/null 2>&1; then
|
if type "xorg$action" >/dev/null 2>&1; then
|
||||||
"xorg$action" "$@"
|
"xorg$action" "$@"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
sway|river)
|
sway|river)
|
||||||
# We don't yet support everything
|
# We don't yet support everything
|
||||||
if type "wl$action" >/dev/null 2>&1; then
|
if type "wl$action" >/dev/null 2>&1; then
|
||||||
"wl$action" "$@"
|
"wl$action" "$@"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# invoke action covering all wms
|
# invoke action covering all wms
|
||||||
if type "wm_generic_$action" >/dev/null 2>&1; then
|
if type "wm_generic_$action" >/dev/null 2>&1; then
|
||||||
"wm_generic_$action" "$@"
|
"wm_generic_$action" "$@"
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
printf "%s not implemented for %s\n" "$action" "$SXMO_WM" >&2
|
printf "%s not implemented for %s\n" "$action" "$SXMO_WM" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch "$@"
|
dispatch "$@"
|
||||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user