init commit
This commit is contained in:
Executable
BIN
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
export SXMO_WM=sway
|
||||
export SXMO_ROTATION=normal
|
||||
|
||||
# Native 1:1 240x320 QVGA resolution
|
||||
export SXMO_SWAY_SCALE=1
|
||||
|
||||
# Physical button mappings
|
||||
export SXMO_POWER_BUTTON="0:0:pm8916_pon"
|
||||
export SXMO_VOLUME_UP_BUTTON="0:103:KEY_UP"
|
||||
export SXMO_VOLUME_DOWN_BUTTON="0:108:KEY_DOWN"
|
||||
export SXMO_MENU_LEFT_BUTTON="0:139:KEY_MENU"
|
||||
export SXMO_MENU_RIGHT_BUTTON="0:158:KEY_BACK"
|
||||
export SXMO_ENTER_BUTTON="0:352:KEY_OK"
|
||||
|
||||
# Nokia 8110 4G has a physical keypad and no touchscreen
|
||||
export SXMO_NO_VIRTUAL_KEYBOARD=1
|
||||
export KEYBOARD_ARGS="-H 1 -L 1"
|
||||
export SXMO_MENU=wofi
|
||||
export SXMO_WOFI_LANDSCAPE_WIDTH=320
|
||||
export SXMO_WOFI_LANDSCAPE_HEIGHT=200
|
||||
export SXMO_BEMENU_PORTRAIT_LINES=10
|
||||
export SXMO_BEMENU_LANDSCAPE_LINES=6
|
||||
export BEMENU_OPTS="--fn 'Sxmo 13' -H 24"
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
export SXMO_WM=sway
|
||||
export SXMO_ROTATION=normal
|
||||
|
||||
# Native 1:1 240x320 QVGA resolution
|
||||
export SXMO_SWAY_SCALE=1
|
||||
|
||||
# Physical button mappings
|
||||
export SXMO_POWER_BUTTON="0:0:pm8916_pon"
|
||||
export SXMO_VOLUME_UP_BUTTON="0:103:KEY_UP"
|
||||
export SXMO_VOLUME_DOWN_BUTTON="0:108:KEY_DOWN"
|
||||
export SXMO_MENU_LEFT_BUTTON="0:139:KEY_MENU"
|
||||
export SXMO_MENU_RIGHT_BUTTON="0:158:KEY_BACK"
|
||||
export SXMO_ENTER_BUTTON="0:352:KEY_OK"
|
||||
|
||||
# Nokia 8110 4G has a physical keypad and no touchscreen
|
||||
export SXMO_NO_VIRTUAL_KEYBOARD=1
|
||||
export KEYBOARD_ARGS="-H 1 -L 1"
|
||||
export SXMO_MENU=wofi
|
||||
export SXMO_WOFI_LANDSCAPE_WIDTH=320
|
||||
export SXMO_WOFI_LANDSCAPE_HEIGHT=200
|
||||
export SXMO_BEMENU_PORTRAIT_LINES=10
|
||||
export SXMO_BEMENU_LANDSCAPE_LINES=6
|
||||
export BEMENU_OPTS="--fn 'Sxmo 13' -H 24"
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
export SXMO_WM=sway
|
||||
export SXMO_ROTATION=normal
|
||||
|
||||
# Native 1:1 240x320 QVGA resolution
|
||||
export SXMO_SWAY_SCALE=1
|
||||
|
||||
# Physical button mappings
|
||||
export SXMO_POWER_BUTTON="0:0:pm8916_pon"
|
||||
export SXMO_VOLUME_UP_BUTTON="0:103:KEY_UP"
|
||||
export SXMO_VOLUME_DOWN_BUTTON="0:108:KEY_DOWN"
|
||||
export SXMO_MENU_LEFT_BUTTON="0:139:KEY_MENU"
|
||||
export SXMO_MENU_RIGHT_BUTTON="0:158:KEY_BACK"
|
||||
export SXMO_ENTER_BUTTON="0:352:KEY_OK"
|
||||
|
||||
# Nokia 8110 4G has a physical keypad and no touchscreen
|
||||
export SXMO_NO_VIRTUAL_KEYBOARD=1
|
||||
export KEYBOARD_ARGS="-H 1 -L 1"
|
||||
export SXMO_MENU=wofi
|
||||
export SXMO_WOFI_LANDSCAPE_WIDTH=320
|
||||
export SXMO_WOFI_LANDSCAPE_HEIGHT=200
|
||||
export SXMO_BEMENU_PORTRAIT_LINES=10
|
||||
export SXMO_BEMENU_LANDSCAPE_LINES=6
|
||||
export BEMENU_OPTS="--fn 'Sxmo 13' -H 24"
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
export SXMO_WM=sway
|
||||
export SXMO_ROTATION=normal
|
||||
|
||||
# Native 1:1 240x320 QVGA resolution
|
||||
export SXMO_SWAY_SCALE=1
|
||||
|
||||
# Physical button mappings
|
||||
export SXMO_POWER_BUTTON="0:0:pm8916_pon"
|
||||
export SXMO_VOLUME_UP_BUTTON="0:103:KEY_UP"
|
||||
export SXMO_VOLUME_DOWN_BUTTON="0:108:KEY_DOWN"
|
||||
export SXMO_MENU_LEFT_BUTTON="0:139:KEY_MENU"
|
||||
export SXMO_MENU_RIGHT_BUTTON="0:158:KEY_BACK"
|
||||
export SXMO_ENTER_BUTTON="0:352:KEY_OK"
|
||||
|
||||
# Nokia 8110 4G has a physical keypad and no touchscreen
|
||||
export SXMO_NO_VIRTUAL_KEYBOARD=1
|
||||
export KEYBOARD_ARGS="-H 1 -L 1"
|
||||
export SXMO_MENU=wofi
|
||||
export SXMO_WOFI_LANDSCAPE_WIDTH=320
|
||||
export SXMO_WOFI_LANDSCAPE_HEIGHT=200
|
||||
export SXMO_BEMENU_PORTRAIT_LINES=10
|
||||
export SXMO_BEMENU_LANDSCAPE_LINES=6
|
||||
export BEMENU_OPTS="--fn 'Sxmo 13' -H 24"
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
export SXMO_WM=sway
|
||||
export SXMO_ROTATION=normal
|
||||
|
||||
# Native 1:1 240x320 QVGA resolution
|
||||
export SXMO_SWAY_SCALE=1
|
||||
|
||||
# Physical button mappings
|
||||
export SXMO_POWER_BUTTON="0:0:pm8916_pon"
|
||||
export SXMO_VOLUME_UP_BUTTON="0:103:KEY_UP"
|
||||
export SXMO_VOLUME_DOWN_BUTTON="0:108:KEY_DOWN"
|
||||
export SXMO_MENU_LEFT_BUTTON="0:139:KEY_MENU"
|
||||
export SXMO_MENU_RIGHT_BUTTON="0:158:KEY_BACK"
|
||||
export SXMO_ENTER_BUTTON="0:352:KEY_OK"
|
||||
|
||||
# Nokia 8110 4G has a physical keypad and no touchscreen
|
||||
export SXMO_NO_VIRTUAL_KEYBOARD=1
|
||||
export KEYBOARD_ARGS="-H 1 -L 1"
|
||||
export SXMO_MENU=wofi
|
||||
export SXMO_WOFI_LANDSCAPE_WIDTH=320
|
||||
export SXMO_WOFI_LANDSCAPE_HEIGHT=200
|
||||
export SXMO_BEMENU_PORTRAIT_LINES=10
|
||||
export SXMO_BEMENU_LANDSCAPE_LINES=6
|
||||
export BEMENU_OPTS="--fn 'Sxmo 13' -H 24"
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec sxmo_hook_inputhandler.sh "$@"
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
|
||||
usage() {
|
||||
printf "usage: %s [reboot|poweroff|logout|togglewm]\n" "$(basename "$0")"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
reboot)
|
||||
sxmo_hook_power.sh reboot || true
|
||||
sxmo_jobs.sh stop all >/dev/null 2>&1 || true
|
||||
sync
|
||||
(sleep 5; doas /sbin/reboot -f >/dev/null 2>&1) &
|
||||
doas /sbin/reboot || doas reboot || doas /sbin/reboot -f
|
||||
;;
|
||||
poweroff)
|
||||
sxmo_hook_power.sh poweroff || true
|
||||
sxmo_jobs.sh stop all >/dev/null 2>&1 || true
|
||||
sync
|
||||
(sleep 5; doas /sbin/poweroff -f >/dev/null 2>&1) &
|
||||
doas /sbin/poweroff || doas poweroff || doas /sbin/poweroff -f
|
||||
;;
|
||||
logout)
|
||||
sxmo_hook_logout.sh || true
|
||||
case "$SXMO_WM" in
|
||||
"i3") i3-msg exit ;;
|
||||
"sway") swaymsg exit ;;
|
||||
"river") riverctl exit ;;
|
||||
"dwm") pkill dwm ;;
|
||||
esac
|
||||
;;
|
||||
togglewm) sxmo_togglewm.sh ;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
# Run from sway.
|
||||
|
||||
# include common definitions
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
|
||||
monitor="${SXMO_MONITOR:-"$(swaymsg -t get_outputs | jq -r '.[0] | .name')"}"
|
||||
pwr="$SXMO_POWER_BUTTON"
|
||||
vols="$SXMO_VOLUME_BUTTON"
|
||||
|
||||
# Drop this when bonsai is available on 32 bits systems
|
||||
multikey_retrocompat() {
|
||||
sxmo_multikey.sh clear
|
||||
|
||||
if [ -n "$pwr" ]; then
|
||||
swaymsg -- input "$pwr" repeat_delay 200
|
||||
swaymsg -- input "$pwr" repeat_rate 15
|
||||
swaymsg -- bindsym --locked XF86PowerOff exec sxmo_multikey.sh \
|
||||
powerbutton \
|
||||
powerbutton_one \
|
||||
powerbutton_two \
|
||||
powerbutton_three
|
||||
else
|
||||
swaymsg -- bindsym --locked XF86PowerOff exec \
|
||||
sxmo_hook_inputhandler.sh powerbutton_one
|
||||
fi
|
||||
|
||||
if [ -n "$vols" ]; then
|
||||
for vol in $vols; do
|
||||
swaymsg -- input "$vol" repeat_delay 200
|
||||
swaymsg -- input "$vol" repeat_rate 15
|
||||
|
||||
swaymsg -- bindsym --locked --input-device="$vol" XF86AudioRaiseVolume exec \
|
||||
sxmo_multikey.sh \
|
||||
volup \
|
||||
volup_one \
|
||||
volup_two \
|
||||
volup_three
|
||||
|
||||
swaymsg -- bindsym --locked --input-device="$vol" XF86AudioLowerVolume exec \
|
||||
sxmo_multikey.sh \
|
||||
voldown \
|
||||
voldown_one \
|
||||
voldown_two \
|
||||
voldown_three
|
||||
done
|
||||
else
|
||||
swaymsg -- bindsym --locked XF86AudioRaiseVolume exec \
|
||||
sxmo_hook_inputhandler.sh volup_one
|
||||
swaymsg -- bindsym --locked XF86AudioLowerVolume exec \
|
||||
sxmo_hook_inputhandler.sh voldown_one
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -n "$SXMO_MODEM_GPIO_KEY_RI" ]; then
|
||||
# Disable the gpio-key-ri input devive
|
||||
# It will trigger idle wakeup on modem notification which break sxmo
|
||||
swaymsg -- input "$SXMO_MODEM_GPIO_KEY_RI" events disabled
|
||||
fi
|
||||
|
||||
if [ -n "$SXMO_SWAY_SCALE" ]; then
|
||||
swaymsg -- output "$monitor" scale "$SXMO_SWAY_SCALE"
|
||||
fi
|
||||
|
||||
swaymsg -- layout splitv >/dev/null 2>&1 || true
|
||||
swaymsg -- splitv >/dev/null 2>&1 || true
|
||||
|
||||
focused_name="$(
|
||||
swaymsg -t get_outputs | jq -r '.[] | select(.focused == true) | .name'
|
||||
)"
|
||||
swaymsg -- input type:touch map_to_output "$focused_name"
|
||||
swaymsg -- input type:tablet_tool map_to_output "$focused_name"
|
||||
|
||||
if [ -n "$SXMO_DISABLE_KEYBINDS" ]; then
|
||||
swaymsg -- bindsym --locked XF86PowerOff exec \
|
||||
sxmo_hook_inputhandler.sh powerbutton_one
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! command -v bonsaictl > /dev/null; then
|
||||
multikey_retrocompat
|
||||
exit
|
||||
fi
|
||||
|
||||
swaymsg -- bindsym --locked --no-repeat XF86PowerOff exec bonsaictl -e power_pressed
|
||||
swaymsg -- bindsym --locked --release XF86PowerOff exec bonsaictl -e power_released
|
||||
|
||||
swaymsg -- bindsym --locked --no-repeat XF86AudioRaiseVolume exec bonsaictl -e volup_pressed
|
||||
swaymsg -- bindsym --locked --release XF86AudioRaiseVolume exec bonsaictl -e volup_released
|
||||
|
||||
swaymsg -- bindsym --locked --no-repeat XF86AudioLowerVolume exec bonsaictl -e voldown_pressed
|
||||
swaymsg -- bindsym --locked --release XF86AudioLowerVolume exec bonsaictl -e voldown_released
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
# include common definitions
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
|
||||
change_alpine() {
|
||||
echo "Changing timezone to $1"
|
||||
|
||||
doas setup-timezone -z "$1"
|
||||
sxmo_hook_statusbar.sh time
|
||||
|
||||
echo "Timezone changed ok"
|
||||
}
|
||||
|
||||
change_systemd() {
|
||||
echo "Changing timezone to $1"
|
||||
|
||||
timedatectl set-timezone "$1"
|
||||
sxmo_hook_statusbar.sh time
|
||||
|
||||
echo "Timezone changed ok"
|
||||
}
|
||||
|
||||
menu() {
|
||||
zoneinfo_dir=$(xdg_data_path zoneinfo)
|
||||
T="$(
|
||||
find "$zoneinfo_dir" -type f |
|
||||
sed "s#^${zoneinfo_dir}/##g" |
|
||||
sort |
|
||||
sxmo_dmenu.sh -p Timezone -i
|
||||
)" || exit 0
|
||||
sxmo_terminal.sh "$0" "$T"
|
||||
}
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
trap "read -r" EXIT
|
||||
set -e
|
||||
|
||||
case "$SXMO_OS" in
|
||||
alpine|postmarketos|bananarchy) change_alpine "$@";;
|
||||
arch|archarm|debian) change_systemd "$@";;
|
||||
nixos) echo "Change the timezone in configuration.nix with time.timeZone = \"[timezone]\"";;
|
||||
*) echo "Changing the timezone isn't implemented on your distro yet";;
|
||||
esac
|
||||
else
|
||||
menu
|
||||
fi
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
# include common definitions
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
|
||||
trap "read -r" EXIT
|
||||
|
||||
update_apk() {
|
||||
echo "Updating all packages from repositories"
|
||||
doas apk update
|
||||
|
||||
echo "Upgrading all packages"
|
||||
doas apk upgrade -aiv
|
||||
|
||||
echo "Upgrade complete - reboot for all changes to take effect"
|
||||
}
|
||||
|
||||
update_pacman() {
|
||||
echo "Upgrading all packages"
|
||||
doas pacman -Syu
|
||||
|
||||
echo "Upgrade complete - reboot for all changes to take effect"
|
||||
}
|
||||
|
||||
update_nixos() {
|
||||
echo "Upgrading all packages"
|
||||
# nohup needed because nixos-rebuild might restart the display manager
|
||||
# (and thus the terminal we're running in) before the update is complete
|
||||
doas nohup nixos-rebuild switch --upgrade > /tmp/sxmo-last-upgrade.log &
|
||||
coreutils --coreutils-prog=tail -f /tmp/sxmo-last-upgrade.log --pid=$!
|
||||
|
||||
echo "Upgrade complete - reboot for all changes to take effect"
|
||||
}
|
||||
|
||||
sxmo_wakelock.sh lock sxmo_upgrading infinite
|
||||
|
||||
case "$SXMO_OS" in
|
||||
alpine|postmarketos|bananarchy) update_apk;;
|
||||
arch|archarm) update_pacman;;
|
||||
nixos) update_nixos;;
|
||||
esac
|
||||
|
||||
sxmo_wakelock.sh unlock sxmo_upgrading
|
||||
Executable
+533
@@ -0,0 +1,533 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
# shellcheck disable=SC2317 disable=SC2329
|
||||
# include common definitions
|
||||
# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh
|
||||
. sxmo_hook_icons.sh
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
|
||||
swi3msg() {
|
||||
case "$SXMO_WM" in
|
||||
sway) swaymsg "$@" ;;
|
||||
i3) i3-msg "$@" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Output Power Management {{{
|
||||
xorgdisplay() {
|
||||
case "$1" in
|
||||
off)
|
||||
xset dpms 0 0 3
|
||||
xset dpms force off
|
||||
;;
|
||||
on)
|
||||
xset dpms 0 0 0
|
||||
xset dpms force on
|
||||
;;
|
||||
"")
|
||||
if xset q | grep -q "Off: 3"; then
|
||||
printf "off\n"
|
||||
else
|
||||
printf "on\n"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
printf 'sxmo_wm.sh display: unknown command "%s"\n' "$1" >&2
|
||||
printf 'Usage: sxmo_wm.sh display [on|off]\n' >&2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
wldisplay() {
|
||||
case "$1" in
|
||||
on) wlopm --on "*" ;;
|
||||
off) wlopm --off "*";;
|
||||
"")
|
||||
if wlopm | grep -q "on"; then
|
||||
printf "on\n"
|
||||
else
|
||||
printf "off\n"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
printf 'sxmo_wm.sh display: unknown command "%s"\n' "$1" >&2
|
||||
printf 'Usage: sxmo_wm.sh display [on|off]\n' >&2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
wm_generic_dpms() {
|
||||
sxmo_log "WARNING: $0: the dpms subcommand is deprecated, use display instead"
|
||||
|
||||
# The dpms command was origionally implemented with on/off being the
|
||||
# opposite of what they should have been. Swap them for backwards
|
||||
# compatability.
|
||||
case "$1" in
|
||||
on)
|
||||
shift
|
||||
set -- "off" "$@"
|
||||
;;
|
||||
off)
|
||||
shift
|
||||
set -- "on" "$@"
|
||||
;;
|
||||
esac
|
||||
|
||||
dispatch display "$@"
|
||||
}
|
||||
# }}}
|
||||
|
||||
# inputevent {{{
|
||||
xorginputevent() {
|
||||
if [ "$1" = "touchscreen" ]; then
|
||||
TOUCH_POINTER_ID="$SXMO_TOUCHSCREEN_ID"
|
||||
elif [ "$1" = "stylus" ]; then
|
||||
TOUCH_POINTER_ID="$SXMO_STYLUS_ID"
|
||||
fi
|
||||
|
||||
if [ -z "$TOUCH_POINTER_ID" ]; then
|
||||
echo "not found"
|
||||
return 0
|
||||
fi
|
||||
|
||||
STATE=off
|
||||
if xinput list-props "$TOUCH_POINTER_ID" | \
|
||||
grep "Device Enabled" | \
|
||||
grep -q "1$"; then
|
||||
STATE=on
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
printf %s "$STATE"
|
||||
elif [ "$2" = on ] && [ "$STATE" != on ]; then
|
||||
xinput enable "$TOUCH_POINTER_ID"
|
||||
elif [ "$2" = off ] && [ "$STATE" != off ] ; then
|
||||
xinput disable "$TOUCH_POINTER_ID"
|
||||
fi
|
||||
}
|
||||
|
||||
swayinputevent() {
|
||||
if [ "$1" = "touchscreen" ]; then
|
||||
TOUCH_POINTER_ID="touch"
|
||||
elif [ "$1" = "stylus" ]; then
|
||||
TOUCH_POINTER_ID="tablet_tool"
|
||||
fi
|
||||
|
||||
# If we dont have any matching input
|
||||
if ! swaymsg -t get_inputs \
|
||||
| jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" )" \
|
||||
| grep -q .; then
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
printf "not found"
|
||||
exit 0
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
STATE=on
|
||||
if swaymsg -t get_inputs \
|
||||
| jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" ) | .libinput.send_events" \
|
||||
| grep -q "disabled"; then
|
||||
STATE=off
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
printf %s "$STATE"
|
||||
elif [ "$2" = on ] && [ "$STATE" != on ]; then
|
||||
swaymsg "input type:$TOUCH_POINTER_ID events enabled" > /dev/null
|
||||
elif [ "$2" = off ] && [ "$STATE" != off ] ; then
|
||||
swaymsg "input type:$TOUCH_POINTER_ID events disabled" > /dev/null
|
||||
fi
|
||||
}
|
||||
# }}}
|
||||
|
||||
# focusedwindow {{{
|
||||
_xorgfocusedwindow() {
|
||||
xprop -id "$(xdotool getactivewindow 2>/dev/null)" 2>/dev/null | awk '
|
||||
/^WM_CLASS/ {
|
||||
sub(/^WM_CLASS[^=]*= ?"[^"]*", "/, "")
|
||||
sub(/"$/, "")
|
||||
class = $0
|
||||
}
|
||||
/^WM_NAME/ {
|
||||
sub(/^WM_NAME[^=]*= ?"/, "")
|
||||
sub(/"$/, "")
|
||||
title = $0
|
||||
}
|
||||
END { printf "%s\n%s\n", tolower(class), tolower(title) }
|
||||
'
|
||||
}
|
||||
|
||||
_swi3_focusedwindow() {
|
||||
swi3msg -t get_tree | jq -r '
|
||||
recurse(.nodes[]) |
|
||||
select(.focused == true) |
|
||||
{
|
||||
app_id: (if .app_id != null then
|
||||
.app_id
|
||||
else
|
||||
.window_properties.class
|
||||
end) | gsub("\n"; "\\n") | ascii_downcase,
|
||||
name: (.name | gsub("\n"; "\\n") | ascii_downcase),
|
||||
} |
|
||||
select(.app_id != null and .name != null) |
|
||||
"\(.app_id)\n\(.name)"
|
||||
'
|
||||
}
|
||||
|
||||
_raw_focusedwindow() {
|
||||
case "$SXMO_WM" in
|
||||
dwm) _xorgfocusedwindow ;;
|
||||
sway|i3) _swi3_focusedwindow ;;
|
||||
river) lswt -j | jq -r '
|
||||
.toplevels |
|
||||
map(select(.activated))[0] |
|
||||
(."app-id" | ascii_downcase), (.title | ascii_downcase)
|
||||
'
|
||||
esac
|
||||
}
|
||||
|
||||
wm_generic_focusedwindow() {
|
||||
if [ "$1" = "-r" ]; then
|
||||
_raw_focusedwindow
|
||||
else
|
||||
# This script originally output this format, which is a bit
|
||||
# harder to parse. Keep it for backwards compatibility in case
|
||||
# anyone was using it.
|
||||
_raw_focusedwindow | {
|
||||
read -r app
|
||||
read -r title
|
||||
printf "app: %s\ntitle: %s\n" "$app" "$title"
|
||||
}
|
||||
fi
|
||||
}
|
||||
# }}}
|
||||
|
||||
# paste {{{
|
||||
wlpaste() {
|
||||
wl-paste
|
||||
}
|
||||
|
||||
xorgpaste() {
|
||||
xclip -o
|
||||
}
|
||||
# }}}
|
||||
|
||||
# exec {{{
|
||||
wm_generic__swi3exec_inner() {
|
||||
cmd="$(cat "$1")"
|
||||
rm "$1"
|
||||
eval "$cmd"
|
||||
}
|
||||
|
||||
swi3exec() {
|
||||
set -e
|
||||
|
||||
cmdfile="$(mktemp)"
|
||||
jq -r --null-input '$ARGS.positional | @sh' --args -- "$@" > "$cmdfile"
|
||||
|
||||
swi3msg exec "sxmo_wm.sh _swi3exec_inner '$cmdfile'" > /dev/null
|
||||
}
|
||||
|
||||
riverexec() {
|
||||
riverctl spawn "$@"
|
||||
}
|
||||
|
||||
xorgexec() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
"$@" &
|
||||
}
|
||||
# }}}
|
||||
|
||||
# execwait {{{
|
||||
wm_generic__execwait_inner() {
|
||||
notify_file="$1/done"
|
||||
shift
|
||||
|
||||
# This opens the pipe for writing, when this process exits it will be
|
||||
# closed, which will send eof to the monitoring process.
|
||||
exec 3>"$notify_file"
|
||||
|
||||
"$@"
|
||||
}
|
||||
|
||||
_execwait() {
|
||||
set -e
|
||||
runner="$1"
|
||||
shift
|
||||
|
||||
notify_dir="$(mktemp -d)"
|
||||
mkfifo "$notify_dir/done"
|
||||
|
||||
"$runner" sxmo_wm.sh _execwait_inner "$notify_dir" "$@"
|
||||
|
||||
exec 3<"$notify_dir/done"
|
||||
|
||||
# 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.
|
||||
rm -r "$notify_dir"
|
||||
|
||||
# Wait for the notification file to be closed
|
||||
read -r _ <&3 || true
|
||||
}
|
||||
|
||||
swi3execwait() {
|
||||
_execwait swi3exec "$@"
|
||||
}
|
||||
|
||||
riverexecwait() {
|
||||
_execwait riverexec "$@"
|
||||
}
|
||||
|
||||
xorgexecwait() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
exec "$@"
|
||||
}
|
||||
# }}}
|
||||
|
||||
# toggle layout {{{
|
||||
swi3togglelayout() {
|
||||
swi3msg "layout toggle splitv splith tabbed" > /dev/null
|
||||
}
|
||||
|
||||
dwmtogglelayout() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
xdotool key --clearmodifiers key Super+space
|
||||
}
|
||||
|
||||
rivertogglelayout() {
|
||||
riverctl toggle-fullscreen
|
||||
}
|
||||
# }}}
|
||||
|
||||
# switch focus {{{
|
||||
i3switchfocus() {
|
||||
sxmo_wmmenu.sh i3windowswitcher
|
||||
}
|
||||
|
||||
swayswitchfocus() {
|
||||
sxmo_wmmenu.sh swaywindowswitcher
|
||||
}
|
||||
|
||||
dwmswitchfocus() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
xdotool key --clearmodifiers Super+x
|
||||
}
|
||||
# }}}
|
||||
|
||||
# workspace switching {{{
|
||||
_swi3getcurrentworkspace() {
|
||||
swi3msg -t get_workspaces | jq -r '.[] | select(.focused).name'
|
||||
}
|
||||
|
||||
_swi3getnextworkspace() {
|
||||
value="$(($(_swi3getcurrentworkspace)+1))"
|
||||
if [ "$value" -eq "$((${SXMO_WORKSPACE_WRAPPING:-4}+1))" ]; then
|
||||
printf 1
|
||||
else
|
||||
printf %s "$value"
|
||||
fi
|
||||
}
|
||||
|
||||
_swi3getpreviousworkspace() {
|
||||
value="$(($(_swi3getcurrentworkspace)-1))"
|
||||
if [ "$value" -lt 1 ]; then
|
||||
if [ "${SXMO_WORKSPACE_WRAPPING:-4}" -ne 0 ]; then
|
||||
printf %s "${SXMO_WORKSPACE_WRAPPING:-4}"
|
||||
else
|
||||
return 1 # cant have previous workspace
|
||||
fi
|
||||
else
|
||||
printf %s "$value"
|
||||
fi
|
||||
}
|
||||
|
||||
swi3nextworkspace() {
|
||||
swi3msg "workspace $(_swi3getnextworkspace)" > /dev/null
|
||||
}
|
||||
|
||||
rivernextworkspace() {
|
||||
river-shifttags
|
||||
}
|
||||
|
||||
dwmnextworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
xdotool key --clearmodifiers Super+Shift+r
|
||||
}
|
||||
|
||||
swi3previousworkspace() {
|
||||
swi3msg "workspace $(_swi3getpreviousworkspace )" > /dev/null
|
||||
}
|
||||
|
||||
dwmpreviousworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
xdotool key --clearmodifiers Super+Shift+e
|
||||
}
|
||||
|
||||
riverpreviousworkspace() {
|
||||
river-shifttags --shift -1
|
||||
}
|
||||
|
||||
swi3movenextworkspace() {
|
||||
swi3msg "move container to workspace $(_swi3getnextworkspace)" > /dev/null
|
||||
}
|
||||
|
||||
dwmmovenextworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
xdotool key --clearmodifiers Super+r
|
||||
}
|
||||
|
||||
swi3movepreviousworkspace() {
|
||||
swi3msg "move container to workspace $(_swi3getpreviousworkspace )" > /dev/null
|
||||
}
|
||||
|
||||
dwmmovepreviousworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
xdotool key --clearmodifiers Super+e
|
||||
}
|
||||
|
||||
swi3workspace() {
|
||||
swi3msg "workspace $1" > /dev/null
|
||||
}
|
||||
|
||||
riverworkspace() {
|
||||
tags=$((1 << ($1 - 1)))
|
||||
riverctl set-focused-tags "$tags"
|
||||
}
|
||||
|
||||
dwmworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
xdotool key --clearmodifiers "Super+$1"
|
||||
}
|
||||
|
||||
swi3moveworkspace() {
|
||||
swi3msg "move container to workspace $1" > /dev/null
|
||||
}
|
||||
|
||||
rivermoveworkspace() {
|
||||
tags=$((1 << ($1 - 1)))
|
||||
riverctl set-view-tags "$tags"
|
||||
}
|
||||
|
||||
dwmmoveworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
xdotool key --clearmodifiers "Super+shift+$1"
|
||||
}
|
||||
# }}}
|
||||
|
||||
# toggle bar {{{
|
||||
swi3togglebar() {
|
||||
swi3msg "bar mode toggle" > /dev/null
|
||||
}
|
||||
|
||||
dwmtogglebar() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
xdotool key --clearmodifiers "Super+b"
|
||||
}
|
||||
|
||||
rivertogglebar() {
|
||||
if superctl status sxmo_riverbar | grep -q started; then
|
||||
superctl stop sxmo_riverbar
|
||||
else
|
||||
superctl start sxmo_riverbar
|
||||
fi
|
||||
}
|
||||
# }}}
|
||||
|
||||
# configmenuentry {{{
|
||||
wm_generic_configmenuentry() {
|
||||
case "$SXMO_WM" in
|
||||
dwm)
|
||||
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/xinit"
|
||||
;;
|
||||
i3)
|
||||
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/i3"
|
||||
;;
|
||||
river)
|
||||
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/river"
|
||||
;;
|
||||
sway)
|
||||
printf "%s\n" "$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/sway"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
# }}}
|
||||
|
||||
dispatch() {
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "Usage: sxmo_wm.sh <command>" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
action="$1"
|
||||
shift
|
||||
|
||||
# invoke action covering single wm
|
||||
if type "$SXMO_WM$action" >/dev/null 2>&1; then
|
||||
"$SXMO_WM$action" "$@"
|
||||
return
|
||||
fi
|
||||
|
||||
# invoke action covering multiple wms
|
||||
if [ "$SXMO_WM" = "sway" ] || [ "$SXMO_WM" = "i3" ]; then
|
||||
if type "swi3$action" >/dev/null 2>&1; then
|
||||
"swi3$action" "$@"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# invoke action covering all of xorg/wayland
|
||||
case "$SXMO_WM" in
|
||||
dwm|i3)
|
||||
if type "xorg$action" >/dev/null 2>&1; then
|
||||
"xorg$action" "$@"
|
||||
return
|
||||
fi
|
||||
;;
|
||||
sway|river)
|
||||
# We don't yet support everything
|
||||
if type "wl$action" >/dev/null 2>&1; then
|
||||
"wl$action" "$@"
|
||||
return
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# invoke action covering all wms
|
||||
if type "wm_generic_$action" >/dev/null 2>&1; then
|
||||
"wm_generic_$action" "$@"
|
||||
return
|
||||
else
|
||||
printf "%s not implemented for %s\n" "$action" "$SXMO_WM" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
dispatch "$@"
|
||||
Executable
+429
@@ -0,0 +1,429 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
# this script is a menu which lets the user perform some WM actions.
|
||||
|
||||
# include common definitions
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh
|
||||
. sxmo_hook_icons.sh
|
||||
|
||||
set -e
|
||||
|
||||
_movetowssubmenu() {
|
||||
for ws in $(seq "${SXMO_WORKSPACE_WRAPPING:-4}"); do
|
||||
printf "%s Move to WS %s\n" "$ws" "$ws"
|
||||
done
|
||||
}
|
||||
|
||||
# A menu which allows to move windows or toggle floating.
|
||||
swaymovemenu() {
|
||||
CHOICES="$(cat <<EOF
|
||||
$icon_cls Close Menu
|
||||
$icon_aru Move Up
|
||||
$icon_ard Move Down
|
||||
$icon_arl Move Left
|
||||
$icon_arr Move Right
|
||||
$icon_wn2 Toggle Floating
|
||||
$icon_ac1 Move Scratchpad
|
||||
$(_movetowssubmenu)
|
||||
EOF
|
||||
)"
|
||||
|
||||
MOVEINDEX=0
|
||||
while : ; do
|
||||
# Remove current workspace from the list
|
||||
CHOICES="$(
|
||||
printf "%s" "$CHOICES" |
|
||||
grep -v "$(
|
||||
swaymsg -t get_workspaces |
|
||||
jq -r '
|
||||
.[] | select(.focused).name
|
||||
')"
|
||||
)"
|
||||
|
||||
PICKED="$(printf "%s" "$CHOICES" | dmenu -I "$MOVEINDEX" -p "Move menu")"
|
||||
MOVEINDEX="$(($(printf "%s" "$CHOICES" | grep -nm1 "^$PICKED$" | cut -d: -f1) -1))"
|
||||
case "$PICKED" in
|
||||
""|"$icon_cls Close Menu")
|
||||
return
|
||||
;;
|
||||
?" Move to WS "?)
|
||||
sxmo_wm.sh moveworkspace "${PICKED%" Move to WS "?}"
|
||||
return
|
||||
;;
|
||||
"$icon_wn2 Toggle Floating")
|
||||
swaymsg floating toggle
|
||||
;;
|
||||
*)
|
||||
printf "%s" "$PICKED" | tr -cd '\000-\177' | xargs swaymsg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# The generic sway menu
|
||||
swaywmmenu() {
|
||||
WMINDEX=0
|
||||
|
||||
while : ; do
|
||||
# generate layout line with format "current → next → 2nd next"
|
||||
CURRENT_LAYOUT="$(
|
||||
swaymsg -t get_tree |
|
||||
jq -r 'recurse(.nodes[]) |
|
||||
if select(.nodes[].focused).layout=="output" then
|
||||
select(.nodes[].focused).nodes[].layout
|
||||
else select(.nodes[].focused).layout end'
|
||||
)"
|
||||
if [ -n "$CURRENT_LAYOUT" ]; then
|
||||
if [ "$CURRENT_LAYOUT" = "splitv" ]; then
|
||||
LAYOUT_LINE="splitv $icon_arr splith $icon_arr tabbed"
|
||||
elif [ "$CURRENT_LAYOUT" = "splith" ]; then
|
||||
LAYOUT_LINE="splith $icon_arr tabbed $icon_arr splitv"
|
||||
else
|
||||
LAYOUT_LINE="tabbed $icon_arr splitv $icon_arr splith"
|
||||
fi
|
||||
fi
|
||||
CHOICES="$(grep . <<EOF
|
||||
$icon_cls Close Menu
|
||||
$icon_win Next window
|
||||
$icon_mov Move menu
|
||||
$icon_rld Switch menu
|
||||
$([ -n "$CURRENT_LAYOUT" ] && printf "%s" "$icon_rld $LAYOUT_LINE")
|
||||
$icon_mnu Split vertical
|
||||
$icon_grd Split horizontal
|
||||
$icon_tab Tabbed layout
|
||||
$icon_exp Focus parent
|
||||
$icon_trh Kill window
|
||||
EOF
|
||||
)"
|
||||
PICKED="$(printf "%s" "$CHOICES" | grep . | dmenu -I "$WMINDEX" -p "WM Menu")"
|
||||
WMINDEX="$(($(printf "%s" "$CHOICES" | grep -nm1 "^$PICKED$" | cut -d: -f1) -1))"
|
||||
|
||||
case "$PICKED" in
|
||||
""|"$icon_cls Close Menu")
|
||||
return
|
||||
;;
|
||||
"$icon_win Next window")
|
||||
swaymsg focus next
|
||||
return
|
||||
;;
|
||||
"$icon_mov Move menu")
|
||||
swaymovemenu
|
||||
;;
|
||||
"$icon_rld Switch menu")
|
||||
swaywindowswitcher
|
||||
;;
|
||||
"$icon_rld $LAYOUT_LINE")
|
||||
sxmo_wm.sh togglelayout
|
||||
;;
|
||||
"$icon_mnu Split vertical")
|
||||
swaymsg layout splitv
|
||||
swaymsg splitv
|
||||
return
|
||||
;;
|
||||
"$icon_grd Split horizontal")
|
||||
swaymsg layout splith
|
||||
swaymsg splith
|
||||
return
|
||||
;;
|
||||
"$icon_tab Tabbed layout")
|
||||
swaymsg layout tabbed
|
||||
return
|
||||
;;
|
||||
"$icon_exp Focus parent")
|
||||
swaymsg focus parent
|
||||
;;
|
||||
"$icon_trh Kill window")
|
||||
sxmo_killwindow.sh
|
||||
;;
|
||||
*)
|
||||
printf "%s" "$PICKED" | tr -cd '\000-\177' | xargs swaymsg
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# The generic river menu
|
||||
riverwmmenu() {
|
||||
WMINDEX=0
|
||||
|
||||
while : ; do
|
||||
# For now justs swap between fullscreen and tiled.
|
||||
LAYOUT_LINE="tiled $icon_arr fullscreen"
|
||||
CHOICES="$(grep . <<EOF
|
||||
$icon_cls Close Menu
|
||||
$icon_mov Move menu
|
||||
$icon_rld Switch menu
|
||||
$(printf "%s" "$icon_rld $LAYOUT_LINE")
|
||||
$icon_trh Kill window
|
||||
EOF
|
||||
)"
|
||||
PICKED="$(printf "%s" "$CHOICES" | grep . | dmenu -I "$WMINDEX" -p "WM Menu")"
|
||||
WMINDEX="$(($(printf "%s" "$CHOICES" | grep -nm1 "^$PICKED$" | cut -d: -f1) -1))"
|
||||
|
||||
case "$PICKED" in
|
||||
""|"$icon_cls Close Menu")
|
||||
return
|
||||
;;
|
||||
"$icon_mov Move menu")
|
||||
rivermovemenu
|
||||
;;
|
||||
"$icon_rld Switch menu")
|
||||
riverwindowswitcher
|
||||
;;
|
||||
"$icon_rld $LAYOUT_LINE")
|
||||
sxmo_wm.sh togglelayout
|
||||
;;
|
||||
"$icon_trh Kill window")
|
||||
sxmo_killwindow.sh
|
||||
;;
|
||||
*)
|
||||
printf "%s" "$PICKED" | tr -cd '\000-\177' | xargs swaymsg
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
_rivermovetowssubmenu() {
|
||||
for ws in $(seq "${SXMO_WORKSPACE_WRAPPING:-9}"); do
|
||||
printf "%s Move to WS %s\n" "$ws" "$ws"
|
||||
done
|
||||
}
|
||||
|
||||
# A menu which allows to move windows or toggle floating.
|
||||
rivermovemenu() {
|
||||
CHOICES="$(cat <<EOF
|
||||
$icon_cls Close Menu
|
||||
$icon_wn2 Toggle Floating
|
||||
$(_rivermovetowssubmenu)
|
||||
EOF
|
||||
)"
|
||||
|
||||
MOVEINDEX=0
|
||||
while : ; do
|
||||
# Remove current workspace from the list
|
||||
CHOICES="$(
|
||||
printf "%s" "$CHOICES" |
|
||||
grep -v "$(
|
||||
river-bedload -print focused |
|
||||
jq -r ' .[] | .focused_id')"
|
||||
)"
|
||||
|
||||
PICKED="$(printf "%s" "$CHOICES" | dmenu -I "$MOVEINDEX" -p "Move menu")"
|
||||
MOVEINDEX="$(($(printf "%s" "$CHOICES" | grep -nm1 "^$PICKED$" | cut -d: -f1) -1))"
|
||||
case "$PICKED" in
|
||||
""|"$icon_cls Close Menu")
|
||||
return
|
||||
;;
|
||||
?" Move to WS "?)
|
||||
sxmo_wm.sh moveworkspace "${PICKED%" Move to WS "?}"
|
||||
return
|
||||
;;
|
||||
"$icon_wn2 Toggle Floating")
|
||||
riverctl toggle-float
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
riverwindowswitcher() {
|
||||
SWITCHINDEX=0
|
||||
|
||||
while : ; do
|
||||
# There is currently no easy in river to get the tag of a given window,
|
||||
# skip the window part of this menu for now.
|
||||
|
||||
# Get the container ID from the node tree
|
||||
CHOICES="$(
|
||||
cat <<EOF
|
||||
$icon_cls Close Menu
|
||||
$icon_arl Previous Workspace
|
||||
$icon_arr Next Workspace
|
||||
$(_rivermovetowssubmenu | grep -v "$(
|
||||
river-bedload -print focused |
|
||||
jq -r ' .[] | .focused_id')")
|
||||
EOF
|
||||
)"
|
||||
|
||||
PICKED="$(printf "%s" "$CHOICES" | dmenu -p "Switch menu" -I "$SWITCHINDEX")"
|
||||
SWITCHINDEX="$(($(printf "%s" "$CHOICES" | grep -nm1 "^$PICKED$" | cut -d: -f1) -1))"
|
||||
|
||||
case "$PICKED" in
|
||||
""|"$icon_cls Close Menu")
|
||||
return
|
||||
;;
|
||||
"$icon_arr Next Workspace")
|
||||
sxmo_wm.sh nextworkspace
|
||||
;;
|
||||
"$icon_arl Previous Workspace")
|
||||
sxmo_wm.sh previousworkspace
|
||||
;;
|
||||
?" Move to WS "?)
|
||||
sxmo_wm.sh workspace "${PICKED%" Move to WS "?}"
|
||||
return
|
||||
;;
|
||||
## When we'll have proper window switching:
|
||||
# *)
|
||||
# # Requires the actual `id` to be at the end and between parentheses
|
||||
# CON_ID=${PICKED##*(}
|
||||
# CON_ID=${CON_ID%)}
|
||||
# swaymsg "[con_id=$CON_ID]" focus
|
||||
# ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
dwmwmmenu() {
|
||||
WMINDEX=0
|
||||
|
||||
while : ; do
|
||||
CHOICES="$(
|
||||
cat <<EOF
|
||||
$icon_cls Close Menu
|
||||
$(_movetowssubmenu)
|
||||
$icon_rld Shift stack
|
||||
$icon_grd Toggle Layout
|
||||
$icon_trh Kill window
|
||||
EOF
|
||||
)"
|
||||
PICKED="$(printf "%s" "$CHOICES" | dmenu -I "$WMINDEX" -p "WM Menu")"
|
||||
WMINDEX="$(($(printf "%s" "$CHOICES" | grep -nm1 "^$PICKED$" | cut -d: -f1) -1))"
|
||||
case "$PICKED" in
|
||||
""|"$icon_cls Close Menu")
|
||||
return
|
||||
;;
|
||||
?" Move to WS "?)
|
||||
sxmo_wm.sh moveworkspace "${PICKED%" Move to WS "?}"
|
||||
;;
|
||||
"$icon_rld Shift stack")
|
||||
sxmo_wm.sh switchfocus
|
||||
;;
|
||||
"$icon_grd Toggle Layout")
|
||||
sxmo_wm.sh togglelayout
|
||||
;;
|
||||
"$icon_trh Kill window")
|
||||
sxmo_killwindow.sh
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
i3windowswitcher() {
|
||||
SWITCHINDEX=0
|
||||
|
||||
while : ; do
|
||||
FORMAT='"W:" + .workspace + " | " + .app_id + " - " + .name + " (" + .id + ")"'
|
||||
|
||||
WINDOWSLIST="$(
|
||||
i3-msg -t get_tree |
|
||||
jq -r ".nodes[]
|
||||
| {output: .name, content: .nodes[]}
|
||||
| {output: .output, workspace: .content.name, apps: .content
|
||||
| ..
|
||||
| {id: .id?|tostring, name: .name?, app_id: .app_id?, shell: .shell?}
|
||||
| select(.app_id != null or .shell != null)}
|
||||
| {output: .output, workspace: .workspace,
|
||||
id: .apps.id, app_id: .apps.app_id, name: .apps.name }
|
||||
| $FORMAT
|
||||
| tostring
|
||||
"
|
||||
)"
|
||||
|
||||
# Get the container ID from the node tree
|
||||
CHOICES="$(
|
||||
cat <<EOF
|
||||
$icon_cls Close Menu
|
||||
$icon_arl Previous Workspace
|
||||
$icon_arr Next Workspace
|
||||
$WINDOWSLIST
|
||||
EOF
|
||||
)"
|
||||
|
||||
PICKED="$(printf "%s" "$CHOICES" | dmenu -p "Switch menu" -I "$SWITCHINDEX")"
|
||||
SWITCHINDEX="$(($(printf "%s" "$CHOICES" | grep -nm1 "^$PICKED$" | cut -d: -f1) -1))"
|
||||
|
||||
case "$PICKED" in
|
||||
""|"$icon_cls Close Menu")
|
||||
return
|
||||
;;
|
||||
"$icon_arr Next Workspace")
|
||||
sxmo_wm.sh nextworkspace
|
||||
;;
|
||||
"$icon_arl Previous Workspace")
|
||||
sxmo_wm.sh previousworkspace
|
||||
;;
|
||||
*)
|
||||
# Requires the actual `id` to be at the end and between parentheses
|
||||
CON_ID=${PICKED##*(}
|
||||
CON_ID=${CON_ID%)}
|
||||
i3-msg "[con_id=$CON_ID]" focus
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
swaywindowswitcher() {
|
||||
SWITCHINDEX=0
|
||||
|
||||
while : ; do
|
||||
FORMAT='"W:" + .workspace + " | " + .app_id + " - " + .name + " (" + .id + ")"'
|
||||
|
||||
WINDOWSLIST="$(
|
||||
swaymsg -t get_tree |
|
||||
jq -r ".nodes[]
|
||||
| {output: .name, content: .nodes[]}
|
||||
| {output: .output, workspace: .content.name, apps: .content
|
||||
| ..
|
||||
| {id: .id?|tostring, name: .name?, app_id: .app_id?, shell: .shell?}
|
||||
| select(.app_id != null or .shell != null)}
|
||||
| {output: .output, workspace: .workspace,
|
||||
id: .apps.id, app_id: .apps.app_id, name: .apps.name }
|
||||
| $FORMAT
|
||||
| tostring
|
||||
"
|
||||
)"
|
||||
|
||||
# Get the container ID from the node tree
|
||||
CHOICES="$(
|
||||
cat <<EOF
|
||||
$icon_cls Close Menu
|
||||
$icon_arl Previous Workspace
|
||||
$icon_arr Next Workspace
|
||||
$WINDOWSLIST
|
||||
EOF
|
||||
)"
|
||||
|
||||
PICKED="$(printf "%s" "$CHOICES" | dmenu -p "Switch menu" -I "$SWITCHINDEX")"
|
||||
SWITCHINDEX="$(($(printf "%s" "$CHOICES" | grep -nm1 "^$PICKED$" | cut -d: -f1) -1))"
|
||||
|
||||
case "$PICKED" in
|
||||
""|"$icon_cls Close Menu")
|
||||
return
|
||||
;;
|
||||
"$icon_arr Next Workspace")
|
||||
sxmo_wm.sh nextworkspace
|
||||
;;
|
||||
"$icon_arl Previous Workspace")
|
||||
sxmo_wm.sh previousworkspace
|
||||
;;
|
||||
*)
|
||||
# Requires the actual `id` to be at the end and between parentheses
|
||||
CON_ID=${PICKED##*(}
|
||||
CON_ID=${CON_ID%)}
|
||||
swaymsg "[con_id=$CON_ID]" focus
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
"$SXMO_WM$1"
|
||||
exit
|
||||
fi
|
||||
case "$SXMO_WM" in
|
||||
dwm|i3) dwmwmmenu ;;
|
||||
sway) swaywmmenu ;;
|
||||
river) riverwmmenu ;;
|
||||
esac
|
||||
Reference in New Issue
Block a user