6 Commits

Author SHA1 Message Date
bb862e0f89 apps: add Notejot 2023-12-30 11:38:35 +00:00
92b077aa67 sxmo_open: just call xdg-open
xdg-open understands the user's mime preferences more reliably than this SXMO re-implementation
2023-12-30 11:33:48 +00:00
be5021e9d8 only alias jq=gojq if the latter is available 2023-12-30 11:33:48 +00:00
3ba6345b5a sxmo_hook_apps: launch apps via the window manager 2023-12-30 11:33:48 +00:00
12e3906e6b sxmo_migrate: add option to disable configversion checks 2023-12-30 11:33:48 +00:00
54948ab328 apps: add Lemoa 2023-12-30 11:33:48 +00:00
137 changed files with 1161 additions and 3548 deletions

View File

@@ -3,9 +3,9 @@ packages:
- shellcheck
- editorconfig-checker
- shellspec
- gojq
- jq
- icu-dev
- linux-headers
sources:
- https://git.sr.ht/~mil/sxmo-utils
tasks:

1
.gitattributes vendored
View File

@@ -1 +0,0 @@
Makefile export-subst

View File

@@ -1,3 +0,0 @@
tracker https://todo.sr.ht/~mil/sxmo-tickets
development-mailing-list ~mil/sxmo-devel@lists.sr.ht
patch-prefix true

View File

@@ -4,8 +4,6 @@ SYSCONFDIR:=/etc
SHAREDIR=$(PREFIX)/share
MANDIR=$(SHAREDIR)/man
CFLAGS := -Wall -std=c99 -D_POSIX_C_SOURCE=200809L $(CFLAGS)
# use $(PREFIX)/lib/systemd/user for systemd integration
SERVICEDIR:=$(PREFIX)/share/superd/services
@@ -13,98 +11,52 @@ SERVICEDIR:=$(PREFIX)/share/superd/services
EXTERNAL_SERVICES:=1
SCDOC=scdoc
SCD2HTML=scd2html
SCD2HTMLFLAGS =
.PHONY: install test shellcheck shellspec test_legacy_nerdfont docs html-docs \
install-docs install-html-docs install-sway install-dwm install-scripts
.PHONY: install test shellcheck shellspec test_legacy_nerdfont
VERSION ?= unknown
VERSION:=1.15.2
# git archive will expand $Format:true$ to just true, so we can use it to check
# if we should use the version from the tarball, or to generate it now.
ifeq "$Format:true$" "true"
VERSION := $Format:%(describe:tags)$
else
VERSION := $(shell git -c safe.directory="*" describe --tags)
endif
GITVERSION:=$(shell git describe --tags)
OPENRC:=1
CC ?= $(CROSS_COMPILE)gcc
PROGRAMS = \
programs/sxmo_aligned_sleep \
programs/sxmo_sleep \
programs/sxmo_vibrate \
programs/sxmo_status_led
programs/sxmo_vibrate
DOCS = \
docs/sxmo.7 \
docs/sxmo_wakelock.sh.1 \
docs/sxmo_migrate.sh.1 \
docs/sxmo_files.sh.1 \
docs/sxmo_contacts.sh.1 \
HTMLDOCS := $(DOCS:%=%.html)
all: $(PROGRAMS) $(DOCS)
# We convert from SCDOC to HTML , the HTML conversion
# we apply some postprocessing for better internal hyperlinks and styling.
docs/%.html: docs/%.scd
$(SCD2HTML) $(SCD2HTMLFLAGS) < "$<" | \
sed -E -e 's/Georgia/Sans/g' \
-e 's/Menlo/FiraMono Nerd Font, Sxmo, Menlo/g' \
-e 's/See ([A-Z ]+)\./See <a href="#\1">\1<\/a>./g' \
-e 's/\(see ([A-Z ]+)\)/(see <a href="#\1">\1<\/a>)/g' \
-e 's/<u>sxmo_([a-z_\.]+)<\/u>\(([1-9])\)/<a href="sxmo_\1.\2.html"><u>sxmo_\1<\/u><\/a>(\2)/g' | \
sed -e ':loop' \
-e 's/\(href="[^" ]*\) \([^"]*"\)/\1_\2/' \
-e 't loop' > "$@" #this last sed statement replace spaces in href attributes with underscores
docs/sxmo.7
docs/%: docs/%.scd
$(SCDOC) <$< >$@
docs: $(DOCS)
all: $(PROGRAMS) $(DOCS)
html-docs: $(HTMLDOCS)
test: shellcheck shellspec test_legacy_nerdfont test_status_led
test: shellcheck shellspec test_legacy_nerdfont
shellcheck:
find . -type f -name '*.sh' -print0 | xargs -0 shellcheck -x --shell=sh
shellspec: ${PROGRAMS}
shellspec:
shellspec
test_status_led: programs/sxmo_status_led.test
./programs/sxmo_status_led.test
test_legacy_nerdfont: programs/test_legacy_nerdfont
programs/test_legacy_nerdfont < configs/default_hooks/sxmo_hook_icons.sh
programs/sxmo_status_led: LDLIBS := -lm
programs/sxmo_status_led.test: LDLIBS := -lm
programs/test_legacy_nerdfont: LDLIBS := $(shell pkg-config --cflags --libs icu-io)
programs/test_legacy_nerdfont: programs/test_legacy_nerdfont.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $< $(shell pkg-config --cflags --libs icu-io)
programs/%: programs/%.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -o $@
# only used for sxmo_status_led
programs/%.test: programs/%.c
$(CC) $(CPPFLAGS) $(CFLAGS) -DTEST $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -o $@
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $<
clean:
rm -f ${PROGRAMS} ${DOCS} ${HTMLDOCS} programs/test_legacy_nerdfont programs/sxmo_status_led.test
rm -f programs/sxmo_aligned_sleep programs/sxmo_vibrate
install: install-sway install-dwm install-scripts install-docs
install-docs: $(DOCS)
cd docs && find . -type f -name '*.7' -exec install -D -m 0644 "{}" "$(DESTDIR)$(MANDIR)/man7/{}" \; && find . -type f -name '*.1' -exec install -D -m 0644 "{}" "$(DESTDIR)$(MANDIR)/man1/{}" \; && cd ..
install-html-docs: $(HTMLDOCS)
cd docs && find . -type f -name '*.html' -exec install -D -m 0644 "{}" "$(DESTDIR)$(PREFIX)/share/doc/sxmo/html/{}" \; && cd ..
cd docs && find . -type f -name '*.7' -exec install -D -m 0644 "{}" "$(DESTDIR)$(MANDIR)/man7/{}" \; && cd ..
install-sway:
install -D -m 0644 -t $(DESTDIR)$(PREFIX)/share/wayland-sessions/ configs/applications/swmo.desktop
@@ -113,13 +65,13 @@ install-dwm:
install -D -m 0644 -t $(DESTDIR)$(PREFIX)/share/xsessions/ configs/applications/sxmo.desktop
install-scripts: $(PROGRAMS)
cd configs && find . -type f -not -exec install -D -m 0644 "{}" "$(DESTDIR)$(PREFIX)/share/sxmo/{}" \; && cd ..
cd configs && find . -type f -not -name sxmo-setpermissions -exec install -D -m 0644 "{}" "$(DESTDIR)$(PREFIX)/share/sxmo/{}" \; && cd ..
rm -rf "$(DESTDIR)$(PREFIX)/share/sxmo/default_hooks/"
cd configs && find default_hooks -type f -exec install -D -m 0755 "{}" "$(DESTDIR)$(PREFIX)/share/sxmo/{}" \; && cd ..
cd configs && find default_hooks -type l -exec cp -R "{}" "$(DESTDIR)$(PREFIX)/share/sxmo/{}" \; && cd ..
echo "$(VERSION)" > "$(DESTDIR)$(PREFIX)/share/sxmo/version"
[ -n "$(GITVERSION)" ] && echo "$(GITVERSION)" > "$(DESTDIR)$(PREFIX)/share/sxmo/version" || echo "$(VERSION)" > "$(DESTDIR)$(PREFIX)/share/sxmo/version"
cd resources && find . -type f -exec install -D -m 0644 "{}" "$(DESTDIR)$(PREFIX)/share/sxmo/{}" \; && cd ..
@@ -127,8 +79,6 @@ install-scripts: $(PROGRAMS)
install -D -m 0644 -t $(DESTDIR)$(PREFIX)/share/applications/ configs/xdg/mimeapps.list
install -D -m 0644 -t $(DESTDIR)$(SYSCONFDIR)/polkit-1/rules.d/ configs/polkit/01-sensor-claim.rules
install -D -m 0640 -t $(DESTDIR)$(SYSCONFDIR)/doas.d/ configs/doas/sxmo.conf
install -D -m 0644 -T configs/xorg/monitor.conf $(DESTDIR)$(PREFIX)/share/X11/xorg.conf.d/90-monitor.conf
@@ -145,8 +95,8 @@ install-scripts: $(PROGRAMS)
# Bin
install -D -t $(DESTDIR)$(PREFIX)/bin scripts/*/*.sh
install -t $(DESTDIR)$(PREFIX)/bin/ ${PROGRAMS}
setcap 'cap_wake_alarm=ep' $(DESTDIR)$(PREFIX)/bin/sxmo_sleep
install -D programs/sxmo_aligned_sleep $(DESTDIR)$(PREFIX)/bin/
install -D programs/sxmo_vibrate $(DESTDIR)$(PREFIX)/bin/
find $(DESTDIR)$(PREFIX)/share/sxmo/default_hooks/ -type f -exec ./setup_config_version.sh "{}" \;
find $(DESTDIR)$(PREFIX)/share/sxmo/appcfg/ -type f -exec ./setup_config_version.sh "{}" \;
@@ -162,5 +112,7 @@ install-scripts: $(PROGRAMS)
fi
@echo "-------------------------------------------------------------------">&2
@echo "NOTICE: After an upgrade, it is recommended you reboot and when prompted run sxmo_migrate.sh to check and upgrade your configuration files and custom hooks against the defaults (it will not make any changes unless explicitly told to)" >&2
@echo "NOTICE 1: Do not forget to add sxmo-setpermissions to your init system, e.g. for openrc: rc-update add sxmo-setpermissions default && rc-service sxmo-setpermissions start" >&2
@echo "-------------------------------------------------------------------">&2
@echo "NOTICE 2: After an upgrade, it is recommended you reboot and when prompted run sxmo_migrate.sh to check and upgrade your configuration files and custom hooks against the defaults (it will not make any changes unless explicitly told to)" >&2
@echo "-------------------------------------------------------------------">&2

View File

@@ -8,11 +8,11 @@ conky.config = {
draw_shades = true,
font = 'Sxmo:size=13',
use_xft = true,
update_interval = 15,
update_interval = 5,
}
conky.text = [[
${alignc}${font Sxmo:size=50:style=Bold}${time %H}${font Sxmo:size=50}:${time %M}${font}
${alignc}${font Sxmo:size=50:style=Bold}${exec date +"%H"}${font Sxmo:size=50}:${exec date +"%M"}${font}
${font Sxmo:size=20}${time %a %d %b %Y}${font}
${font Sxmo:size=20}${exec date +"%a %d %b %Y"}${font}
]]

View File

@@ -5,7 +5,6 @@ text-color=#000000
border-color=#000000
layer=overlay
group-by=app-name
on-touch=invoke-default-action
[urgency=low]
default-timeout=10000

View File

@@ -3474,26 +3474,6 @@ Palivere, Estonia 58.9702778 23.9033337
Aravete, Estonia 59.1416667 25.7613888
Kiili, Estonia 59.3069444 24.8377781
Lagedi, Estonia 59.4055556 24.9422226
Manzini, Eswatini -26.4833333 31.3666668
Mbabane, Eswatini -26.3166667 31.1333332
Big Bend, Eswatini -26.8166667 31.9333324
Malkerns, Eswatini -26.5666667 31.1833324
Mhlume, Eswatini -26.0333333 31.8500004
Hluti, Eswatini -27.2166667 31.6166668
Siteki, Eswatini -26.4500000 31.9500008
Piggs Peak, Eswatini -25.9666667 31.2500000
Lobamba, Eswatini -26.4666667 31.2000008
Kwaluseni, Eswatini -26.4833333 31.3333340
Bhunya, Eswatini -26.5500000 31.0166664
Mhlambanyatsi, Eswatini -26.4500000 31.0166664
Hlatikulu, Eswatini -26.9666667 31.3166676
Bulembu, Eswatini -25.9666667 31.1333332
Kubuta, Eswatini -26.8833333 31.4833336
Tshaneni, Eswatini -25.9833333 31.7166672
Sidvokodvo, Eswatini -26.6166667 31.4500008
Lavumisa, Eswatini -27.3166667 31.8999996
Darkton, Eswatini -26.2333333 31.0333328
Nsoko, Eswatini -27.0333333 31.9500008
Addis Ababa, Ethiopia 9.0333333 38.7000008
Dire Dawa, Ethiopia 9.5930556 41.8661118
Nazret, Ethiopia 8.5500000 39.2666664
@@ -9260,6 +9240,26 @@ Onverwacht, Suriname 5.5833333 -55.1833344
Totness, Suriname 5.8833333 -56.3166656
Benzdorp (Monte Hermon), Suriname 3.6720670 -54.1035461
Kabana-vo, Suriname 3.6741067 -54.0848846
Manzini, Swaziland -26.4833333 31.3666668
Mbabane, Swaziland -26.3166667 31.1333332
Big Bend, Swaziland -26.8166667 31.9333324
Malkerns, Swaziland -26.5666667 31.1833324
Mhlume, Swaziland -26.0333333 31.8500004
Hluti, Swaziland -27.2166667 31.6166668
Siteki, Swaziland -26.4500000 31.9500008
Piggs Peak, Swaziland -25.9666667 31.2500000
Lobamba, Swaziland -26.4666667 31.2000008
Kwaluseni, Swaziland -26.4833333 31.3333340
Bhunya, Swaziland -26.5500000 31.0166664
Mhlambanyatsi, Swaziland -26.4500000 31.0166664
Hlatikulu, Swaziland -26.9666667 31.3166676
Bulembu, Swaziland -25.9666667 31.1333332
Kubuta, Swaziland -26.8833333 31.4833336
Tshaneni, Swaziland -25.9833333 31.7166672
Sidvokodvo, Swaziland -26.6166667 31.4500008
Lavumisa, Swaziland -27.3166667 31.8999996
Darkton, Swaziland -26.2333333 31.0333328
Nsoko, Swaziland -27.0333333 31.9500008
Stockholm, Sweden 59.3325765 18.0649033
Goteborg, Sweden 57.7071623 11.9667931
Malmoe, Sweden 55.6058691 13.0007315
Can't render this file because it has a wrong number of fields in line 2.

View File

@@ -31,7 +31,7 @@ command -v firefox >/dev/null && export BROWSER=firefox
export TERMCMD="sxmo_terminal.sh"
# Change the used terminal command
# export SXMO_TERMINAL="st"
# export SXMO_TERMINAL="st -e"
# When scrolling past the beginning or end of a menu, wrap it around:
#export DMENU_WRAP_AROUND=1
@@ -68,3 +68,6 @@ export SXMO_RINGNUMBER=10
#Set to the default text for a new text message.
export SXMO_DEFAULT_DRAFT="Enter new message here."
#Set background image
export SXMO_BG_IMG="$(xdg_data_path sxmo/background.jpg)"

View File

@@ -31,7 +31,7 @@ mode "menu" {
# to know the device names, so use it as a fallback so this functionality
# keeps working if a deviceprofile doesn't exist.
# TODO: the correct way to do this is to implement custom keybindings in
# bemenu & wofi
# bemenu
bindsym XF86PowerOff exec wtype -k Return
bindsym XF86AudioRaiseVolume exec wtype -k Up
bindsym XF86AudioLowerVolume exec wtype -k Down
@@ -43,15 +43,6 @@ mode "menu" {
#
input * xkb_options compose:ralt
# Nokia N900 hardware keyboard
input "1:1:TWL4030_Keypad" {
xkb_model "nokiarx51"
xkb_layout "us"
# ralt has special meaning on N900 keyboard so do not use as
# compose key
xkb_options compose:rwin
}
# Start a terminal
bindsym $mod+Return exec $term
@@ -164,7 +155,7 @@ mode "menu" {
bindsym $mod+a focus parent
# Manual locker
bindsym $mod+g exec sxmo_state.sh set locker
bindsym $mod+g exec sxmo_hook_locker.sh
# Shutdown
bindsym $mod+t exec sxmo_appmenu.sh power
@@ -222,7 +213,7 @@ bar {
colors {
statusline #ffffff
background #323232
inactive_workspace #323232 #323232 #ffffff
inactive_workspace #32323200 #32323200 #5c5c5c
font "Sxmo 11"
}
}

View File

@@ -1,10 +0,0 @@
# Space to setup configversion
single_click=true
dynamic_lines=true
line_wrap=word
width=80%
height=60%
allow_images=true
allow_markup=true
show=dmenu
no_actions=true

View File

@@ -1,46 +0,0 @@
/* Space to setup configversion */
window {
margin: 5px;
border: 3px solid #005577;
background-color: #222222;
font-family: Sxmo;
font-size: 14pt;
}
#input {
margin: 5px;
border: 2px solid #005577;
background-color: #444444;
color: white;
}
#inner-box {
margin: 5px;
}
#outer-box {
margin: 5px;
}
#scroll {
color: yellow;
}
#text {
margin: 5px;
color: white;
}
#img {
padding-right: 25px;
}
#entry {
padding-top: 8px;
}
#entry:selected {
background-color: #005577;
}
#entry #entry {
background-color: #444444;
}

3
configs/appcfg/xob_styles.cfg Executable file → Normal file
View File

@@ -1,8 +1,7 @@
# Space to setup configversion
default = {
x = {relative = 0.5; offset = 0;};
y = {relative = 0.05; offset = 0;};
y = {relative = 0.15; offset = 0;};
length = {relative = 0.75; offset = 0;};
thickness = 50;
outline = 3;

View File

@@ -15,21 +15,23 @@ write_line_app() {
executable="$1"
label="$2"
command="$3"
inline="$4"
if command -v "$executable" >/dev/null; then
if [ "$inline" != "" ]; then
write_line "$label" "$command"
else
write_line "$label" "sxmo_wm.sh exec $command"
fi
fi
}
write_line_app gnome-2048 "$icon_gam 2048" "gnome-2048"
write_line_app jami-qt "$icon_msg Jami" "jami-qt"
[ -n "$PLAN9" ] && write_line_app acme "$icon_edt Acme" "acme -c 1 -f $PLAN9/font/pelm/ascii.16.font"
write_line_app adventure "$icon_trm Adventure" "sxmo_terminal.sh adventure"
write_line_app aerc "$icon_eml Aerc" "sxmo_terminal.sh aerc"
write_line_app alacritty "$icon_trm Alacritty" "alacritty"
write_line_app amberol "$icon_mus Amberol" "amberol $XDG_MUSIC_DIR"
write_line_app harbour-amazfish-ui "$icon_wat Amazfish" "harbour-amazfish-ui"
write_line_app amfora "$icon_glb Amfora" "sxmo_terminal.sh amfora"
write_line_app angelfish "$icon_glb Angelfish" "angelfish"
write_line_app animatch "$icon_gam Animatch" "animatch"
write_line_app harbour-amazfish-ui "$icon_wat Amazfish" "harbour-amazfish-ui"
write_line_app alpine "$icon_eml Alpine" "sxmo_terminal.sh alpine"
write_line_app anbox-launch "$icon_and Anbox" "anbox"
write_line_app anki "$icon_str Anki" "anki"
@@ -38,18 +40,12 @@ write_line_app badwolf "$icon_glb Badwolf" "badwolf"
write_line_app gnome-calculator "$icon_clc Calculator" "gnome-calculator"
write_line_app calcurse "$icon_clk Calcurse" "sxmo_terminal.sh calcurse"
write_line_app chatty "$icon_msg Chatty" "chatty"
([ "$SXMO_WM" = dwm ] && command -v clipmenu >/dev/null) && \
write_line_app clipmenu "$icon_bok Clipmenu" "clipmenu"
write_line_app cmus "$icon_mus Cmus" "sxmo_terminal.sh cmus"
write_line_app com.github.geigi.cozy "$icon_mus Cozy" "com.github.geigi.cozy"
write_line_app cpupower-gui "$icon_cfg Cpupower-gui" "cpupower-gui"
write_line_app dino "$icon_msg Dino" "GDK_SCALE=1 dino"
write_line_app dolphin "$icon_dir Dolphin" "dolphin"
write_line_app eartag "$icon_mus Eartag" "eartag"
write_line_app elinks "$icon_glb ELinks" "sxmo_terminal.sh elinks"
write_line_app emacs "$icon_edt Emacs (Terminal)" "sxmo_terminal.sh emacs -nw"
write_line_app emacs "$icon_edt Emacs (X)" "emacs"
write_line_app eog "$icon_img Eye of Gnome" "eog"
write_line_app epiphany "$icon_glb Epiphany" "epiphany"
write_line_app epy "$icon_bok Epy" "sxmo_terminal.sh epy"
write_line_app epr "$icon_bok Epr" "sxmo_terminal.sh epr"
@@ -57,12 +53,10 @@ write_line_app evince "$icon_bok Evince" "evince"
write_line_app falkon "$icon_flk Falkon" "falkon"
write_line_app firefox "$icon_ffx Firefox" "firefox"
write_line_app firefox-esr "$icon_ffx Firefox ESR" "firefox-esr"
write_line_app flare "$icon_msg Flare" "flare"
write_line_app foliate "$icon_bok Foliate" "foliate"
( [ "$SXMO_WM" = sway ] && command -v foot >/dev/null) && \
write_line "$icon_trm Foot" "foot $SHELL"
write_line_app foxtrotgps "$icon_gps Foxtrotgps" "foxtrotgps"
write_line_app fractal "$icon_msg Fractal" "fractal"
write_line_app g4music "$icon_mus G4Music" "g4music"
write_line_app geany "$icon_eml Geany" "geany"
write_line_app geary "$icon_eml Geary" "geary"
@@ -71,100 +65,70 @@ write_line_app geeqie "$icon_img Geeqie" "geeqie"
write_line_app geopard "$icon_glb Geopard" "geopard"
write_line_app gerbil "$icon_glb Gerbil" "gerbil"
write_line_app giara "$icon_red Giara" "giara"
write_line_app gnome-2048 "$icon_mvi Gnome-2048" "gnome-2048"
write_line_app gnome-chess "$icon_chs Gnome Chess" "gnome-chess"
write_line_app gnome-firmware "$icon_cfg Gnome Firmware" "gnome-firmware"
write_line_app gnome-weather "$icon_wtr Gnome Weather" "gnome-weather"
write_line_app gnome-disks "$icon_cfg Gnome Disks" "gnome-disks"
write_line_app gomuks "$icon_msg Gomuks" "sxmo_terminal.sh gomuks"
write_line_app gpodder "$icon_rss gPodder" "gpodder"
write_line_app gucharmap "$icon_inf Gucharmap" "gucharmap"
write_line_app hexchat "$icon_msg Hexchat" "hexchat"
write_line_app htop "$icon_cfg Htop" "sxmo_terminal.sh htop"
write_line_app iamb "$icon_msg Iamb" "sxmo_terminal.sh iamb"
write_line_app irssi "$icon_msg Irssi" "sxmo_terminal.sh irssi"
write_line_app ii "$icon_msg Ii" "sxmo_terminal.sh ii"
write_line_app ipython "$icon_trm IPython" "sxmo_terminal.sh ipython"
write_line_app index "$icon_dir Index" "index"
write_line_app itinerary "$icon_map Itinerary" "itinerary"
write_line_app kasts "$icon_rss Kasts" "kasts"
write_line_app kcalc "$icon_clc KCalc" "kcalc"
write_line_app kmail "$icon_eml KMail" "kmail"
write_line_app komikku "$icon_bok Komikku" "komikku"
write_line_app kontact "$icon_msg Kontact" "kontact"
write_line_app konversation "$icon_msg Konversation" "konversation"
write_line_app koreader "$icon_bok KOReader" "koreader"
write_line_app krita "$icon_img Krita" "krita --nosplash"
write_line_app kwrite "$icon_edt Kwrite" "kwrite"
write_line_app lagrange "$icon_glb Lagrange" "lagrange"
write_line_app lemoa "$icon_grp Lemoa" "lemoa"
write_line_app lf "$icon_dir Lf" "sxmo_terminal.sh lf"
write_line_app librewolf "$icon_glb Librewolf" "librewolf"
write_line_app links "$icon_glb Links" "sxmo_terminal.sh links"
write_line_app links "$icon_glb Links (GUI)" "links -g"
write_line_app lollypop "$icon_mus Lollypop" "lollypop"
write_line_app lpa-gtk "$icon_sim Lpa Gtk" "lpa-gtk"
write_line_app luakit "$icon_glb Luakit" "luakit"
write_line_app marble "$icon_map Marble" "marble"
write_line_app gnome-maps "$icon_map Maps" "gnome-maps"
write_line_app megapixels "$icon_cam Megapixels" "megapixels"
write_line_app mepo "$icon_map Mepo" "mepo"
write_line_app metronome "$icon_mtr Metronome" "metronome"
write_line_app micro "$icon_edt Micro" "sxmo_terminal.sh micro"
write_line_app midori "$icon_glb Midori" "midori"
write_line_app moment "$icon_msg Moment" "moment"
write_line_app mupdf "$icon_bok Mupdf" "mupdf"
write_line_app mupdf-gl "$icon_bok Mupdf-gl" "mupdf-gl"
write_line_app mutt "$icon_eml Mutt" "sxmo_terminal.sh mutt"
write_line_app mumble "$icon_grp Mumble" mumble
write_line_app nano "$icon_edt Nano" "sxmo_terminal.sh nano"
write_line_app nautilus "$icon_dir Nautilus" "nautilus"
write_line_app navit "$icon_gps Navit" "navit"
write_line_app ncmpcpp "$icon_mus Ncmpcpp" "sxmo_terminal.sh ncmpcpp"
write_line_app neomutt "$icon_eml Neomutt" "sxmo_terminal.sh neomutt"
write_line_app nethack "$icon_trm Nethack" "sxmo_terminal.sh nethack"
write_line_app nheko "$icon_msg Nheko" "nheko"
write_line_app nvim "$icon_nvi Neovim" "sxmo_terminal.sh nvim"
write_line_app nvim "$icon_vim Neovim" "sxmo_terminal.sh nvim"
write_line_app netsurf "$icon_glb Netsurf" "netsurf"
write_line_app newsboat "$icon_rss Newsboat" "sxmo_terminal.sh newsboat"
write_line_app com.gitlab.newsflash "$icon_rss Newsflash" com.gitlab.newsflash
write_line_app newsraft "$icon_rss Newsraft" "sxmo_terminal.sh newsraft"
write_line_app nnn "$icon_dir Nnn" "sxmo_terminal.sh nnn"
write_line_app io.github.lainsce.Notejot "$icon_drw Notejot" io.github.lainsce.Notejot
write_line_app numberstation "$icon_clc Numberstation" "numberstation"
write_line_app nyxt "$icon_glb Nyxt" "nyxt"
write_line_app offpunk "$icon_glb Offpunk" "sxmo_terminal.sh offpunk"
write_line_app osmin "$icon_map Osmin" "osmin"
write_line_app papers "$icon_bok Papers" "papers"
write_line_app pavucontrol "$icon_mus Pavucontrol" "pavucontrol"
write_line_app pidgin "$icon_msg Pidgin" "pidgin"
write_line_app pulsemixer "$icon_mus Pulsemixer" "sxmo_terminal.sh pulsemixer"
write_line_app pure-maps "$icon_map Pure-Maps" "pure-maps"
write_line_app mepo "$icon_map mepo" "mepo"
write_line_app podboat "$icon_rss Podboat" "sxmo_terminal.sh podboat"
write_line_app dev.tchx84.Portfolio "$icon_dir Portfolio" "dev.tchx84.Portfolio"
write_line_app profanity "$icon_msg Profanity" "sxmo_terminal.sh profanity"
write_line_app pulsemixer "$icon_mus Pulsemixer" "sxmo_terminal.sh pulsemixer"
write_line_app pure-maps "$icon_map Pure Maps" "pure-maps"
write_line_app qalc "$icon_clc Qalc" "sxmo_terminal.sh qalc"
write_line_app qutebrowser "$icon_glb Qutebrowser" "qutebrowser"
write_line_app ranger "$icon_dir Ranger" "sxmo_terminal.sh ranger"
write_line_app sacc "$icon_glb Sacc" "sxmo_terminal.sh sacc i-logout.cz/1/bongusta"
write_line_app secrets "$icon_lck Secrets" "secrets"
write_line_app screen "$icon_msg Screen" "sxmo_terminal.sh screen"
write_line_app seahorse "$icon_key Seahorse" "seahorse"
write_line_app senpai "$icon_msg Senpai" "sxmo_terminal.sh senpai"
write_line_app sic "$icon_msg Sic" "sxmo_terminal.sh sic"
write_line_app siglo "$icon_clk Siglo" "siglo"
write_line_app simple-scan "$icon_scn Simple Scan" "simple-scan"
write_line_app snapshot "$icon_cam Snapshot" "snapshot"
([ "$SXMO_WM" = dwm ] && command -v st >/dev/null) && \
write_line "$icon_trm St" "st -e $SHELL"
write_line_app surf "$icon_glb Surf" "surf"
write_line_app syncthing "$icon_rld Syncthing" "syncthing"
write_line_app syncthing-gtk "$icon_rld Syncthing GTK" "syncthing-gtk"
([ "$SXMO_WM" = dwm ] && command -v tabbed >/dev/null) && \
write_line_app tabbed "$icon_grd Tabbed" "sxmo_tabbed.sh"
write_line_app telegram-desktop "$icon_tgm Telegram" "telegram-desktop"
write_line_app termite "$icon_trm Termite" "termite -e $SHELL"
write_line_app thunar "$icon_dir Thunar" "sxmo_terminal.sh thunar"
write_line_app thunderbird "$icon_eml Thunderbird" "thunderbird"
write_line_app tilix "$icon_trm Tilix" "tilix"
write_line_app com.github.bleakgrey.tootle "$icon_msg Tootle" "com.github.bleakgrey.tootle"
write_line_app re.sonny.Tangram "$icon_glb Tangram" "re.sonny.Tangram"
write_line_app totem "$icon_mvi Totem" "totem"
@@ -174,6 +138,7 @@ write_line_app tut "$icon_msg Tut" "sxmo_terminal.sh tut"
write_line_app waydroid "$icon_and Waydroid" "waydroid show-full-ui"
write_line_app weechat "$icon_msg Weechat" "sxmo_terminal.sh weechat"
write_line_app wike "$icon_bok Wike" "wike"
write_line_app pavucontrol "$icon_mus Pavucontrol" "pavucontrol"
write_line_app w3m "$icon_glb W3m" "sxmo_terminal.sh w3m duck.com"
write_line_app vim "$icon_vim Vim" "sxmo_terminal.sh vim"
write_line_app vimb "$icon_glb Vimb" "vimb"
@@ -183,7 +148,7 @@ write_line_app vte-2.91 "$icon_trm VTE 3" "vte-2.91"
write_line_app vte-2.91-gtk4 "$icon_trm VTE 3 (GTK-4)" "vte-2.91-gtk4"
([ "$SXMO_WM" = dwm ] && command -v xcalc >/dev/null) && \
write_line "$icon_clc Xcalc" "xcalc"
write_line_app xfce4-terminal "$icon_trm XFCE4 Terminal" "xfce4-terminal"
write_line_app xournal "$icon_bok Xournal" "xournal"
write_line_app xournalpp "$icon_bok Xournalpp" "xournalpp"
write_line_app zathura "$icon_bok Zathura" "zathura"
write_line_app j4-dmenu-desktop "$icon_grd All apps" "j4-dmenu-desktop --dmenu=sxmo_dmenu.sh --term=sxmo_terminal.sh --wrapper='sxmo_wm.sh exec'" "inline"

View File

@@ -9,8 +9,6 @@ data_get() {
printf "%b" "$data" | grep "^$1:" | cut -d: -f2
}
SET_LED_PATH="$XDG_RUNTIME_DIR/sxmo_hook_battery_set_led"
device_changed() {
name="$(data_get "native-path")"
state="$(data_get "state")"
@@ -24,14 +22,6 @@ device_changed() {
return
fi
if [ "$percentage" -lt 25 ] && [ ! -f "$SET_LED_PATH" ]; then
touch "$SET_LED_PATH"
sxmo_led.sh set red 100
elif [ -f "$SET_LED_PATH" ]; then
rm "$SET_LED_PATH"
sxmo_led.sh set red 0
fi
sxmo_hook_statusbar.sh battery "$name" "$state" "$percentage"
}

View File

@@ -1,8 +0,0 @@
#!/bin/sh
# This hook is executed to check if a call should be blocked
# If the hook return 0 the call will be blocked
INCOMINGNUMBER="$1"
cut -f1 "$SXMO_BLOCKFILE" 2>/dev/null | grep -q "^$INCOMINGNUMBER$"

View File

@@ -68,12 +68,8 @@ active_mosh() {
command -v mosh-server && pgrep -f mosh-server
}
active_mpc() {
if ! command -v mpc; then
return 1
fi
mpc status | grep -q '\[playing\]\|Updating'
playing_mpc() {
command -v mpc && mpc status | grep -q '\[playing\]'
}
playing_mpris() {
@@ -95,7 +91,7 @@ while [ "$waited" != "0" ]; do
wait_item hotspot_active
wait_item ssh_connected
wait_item active_mosh
wait_item active_mpc
wait_item playing_mpc
wait_item playing_mpris
wait_item photos_processing
done

View File

@@ -9,3 +9,27 @@
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
# Phonecall started
if [ "$1" = "enable" ]; then
sxmo_log "Attempting hack to get things just right."
# fixes bug where sometimes we start with speaker on and mic off
sxmo_modemaudio.sh enable_speaker
sxmo_modemaudio.sh disable_speaker
sxmo_modemaudio.sh mute_mic
sxmo_modemaudio.sh unmute_mic
# Add other things here, e.g., volume boosters
sxmo_modemaudio.sh is_disabled_speaker && sxmo_modemaudio.sh is_unmuted_mic
# Phonecall ended
elif [ "$1" = "disable" ]; then
sxmo_log "Attempting hack to get things just right."
# fixes bug where sometimes we leave call with speaker off
sxmo_modemaudio.sh disable_speaker
sxmo_modemaudio.sh enable_speaker
# Add other things here, e.g., volume boosters
sxmo_modemaudio.sh is_enabled_speaker
fi

View File

@@ -77,8 +77,8 @@ case "$WMCLASS" in
) ^ 1 ^ supertoggle_daemon 'sxmo_hook_lisgd' && (rm $XDG_CACHE_HOME/sxmo/sxmo.nogesture 2>/dev/null || touch $XDG_CACHE_HOME/sxmo/sxmo.nogesture)
$icon_cfg Toggle Bar ^ 0 ^ sxmo_wm.sh togglebar
$icon_bth Bluetooth $(
rfkill list bluetooth -no ID,SOFT,HARD | grep -vq " blocked" &&
printf %b "$icon_ton" || printf %b "$icon_tof";
rfkill list bluetooth | grep -q "yes" &&
printf %b "$icon_tof" || printf %b "$icon_ton";
printf %b "^ 1 ^ doas sxmo_bluetoothtoggle.sh && sxmo_hook_statusbar.sh bluetooth"
)
$(test "$SXMO_WM" = dwm && printf %b "$icon_cfg Invert Colors ^ 1 ^ xcalib -a -invert")
@@ -104,7 +104,6 @@ case "$WMCLASS" in
$icon_cfg Edit configuration ^ 0 ^ sxmo_terminal.sh $EDITOR $XDG_CONFIG_HOME/sxmo/$(test "$SXMO_WM" = sway && printf sway || printf xinit)
$(command -v pmos-tweaks >/dev/null && echo "$icon_cfg PostmarketOS Tweaks ^ 0 ^ GDK_SCALE=1 pmos-tweaks")
$icon_cfg Suspend Blockers ^ 0 ^ sxmo_terminal.sh sxmo_debug_suspend.sh
$icon_inf Log ^ 0 ^ sxmo_terminal.sh tail -n 100 -f ${XDG_STATE_HOME:-$HOME}/sxmo.log
$icon_inf Version ^ 0 ^ sxmo_terminal.sh sxmo_version.sh --block
"
WINNAME=Config
@@ -217,18 +216,9 @@ case "$WMCLASS" in
WINNAME=St
;;
*foot*|*st*|*terminal*|org.gnome.vte.application|*alacritty*)
WMNAME="${1:-$(printf %s "$XPROPOUT" | grep title: | cut -d" " -f2- | tr '[:upper:]' '[:lower:]')}"
# These git commands only launch the editor.
case "$WMNAME" in
*"git add"*|*"git bugreport"*|*"git commit"*|*"git merge"*|*"git notes"*|*"git rebase"*|*"git replace"*|*"git send-email"*|*"git svn"*)
WMNAME="$WMCLASS $EDITOR"
;;
esac
# First we try to handle the app running inside the terminal:
case " $WMNAME " in
*" vi "*|*" vim "*|*" vis "*|*" nvim "*|*neovim*|*kakoune*)
WMNAME="${1:-$(printf %s "$XPROPOUT" | grep title: | cut -d" " -f2- | tr '[:upper:]' '[:lower:]')}"
if printf %s "$WMNAME" | grep -qi -E -w "(vi|vim|vis|nvim|neovim|kakoune)"; then
#Vim in foot
CHOICES="
$icon_cls Save and Quit ^ 0 ^ sxmo_type -k Escape -s 300 ':wq' -k Return
@@ -247,8 +237,7 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=Vim
;;
*nano*)
elif printf %s "$WMNAME" | grep -qi -w "nano"; then
#Nano in foot
CHOICES="
$icon_aru Scroll up ^ 1 ^ sxmo_type -k Prior
@@ -263,8 +252,7 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=Nano
;;
*micro*)
elif printf %s "$WMNAME" | grep -qi -w "micro"; then
#Micro
CHOICES="
$icon_aru Scroll up ^ 1 ^ sxmo_type -k Prior
@@ -282,8 +270,7 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=Micro
;;
*tuir*)
elif printf %s "$WMNAME" | grep -qi -w "tuir"; then
#tuir (reddit client) in foot
CHOICES="
$icon_aru Previous ^ 1 ^ sxmo_type k
@@ -301,8 +288,7 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=tuir
;;
*w3m*)
elif printf %s "$WMNAME" | grep -qi -w "w3m"; then
#w3m
CHOICES="
$icon_arl Back ^ 1 ^ sxmo_type b
@@ -318,8 +304,7 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=w3m
;;
*ncmpcpp*)
elif printf %s "$WMNAME" | grep -qi -w "ncmpcpp"; then
#ncmpcpp
CHOICES="
$icon_lst Playlist ^ 0 ^ sxmo_type 1
@@ -335,8 +320,7 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=ncmpcpp
;;
*aerc*)
elif printf %s "$WMNAME" | grep -qi -w "aerc"; then
#aerc
CHOICES="
$icon_pau Archive ^ 1 ^ sxmo_type ':archive flat' -k Return
@@ -347,8 +331,7 @@ case "$WMCLASS" in
$icon_trm xdg-open Part ^ 0 ^ sxmo_type ':open' -k Return
"
WINNAME=aerc
;;
*less*|*"git blame"*|*"git diff"*|*"git grep"*|*"git help"*|*"git log"*|*"git stash"*|*"git tag"*|*"git var"*)
elif printf %s "$WMNAME" | grep -qi -E -w "(less|mless)"; then
#less
CHOICES="
$icon_arr Page next ^ 1 ^ sxmo_type ':n' -k Return
@@ -361,8 +344,13 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=less
;;
*git*)
elif printf %s "$WMNAME" | grep -qi -w "git \(blame\|diff\|grep\|help\|log\|stash\|tag\|var\)"; then
# These git commands only launch the pager.
exec "$0" "$WMCLASS ${PAGER:-less}"
elif printf %s "$WMNAME" | grep -qi -w "git \(add\|bugreport\|commit\|merge\|notes\|rebase\|replace\|send-email\|svn\)"; then
# These git commands only launch the editor.
exec "$0" "$WMCLASS $EDITOR"
elif printf %s "$WMNAME" | grep -qi -w "git"; then
# git am, branch, config, tag (and other commands which launch both).
CHOICES="
$icon_fil ${PAGER:-less} menu ^ 0 ^ sxmo_appmenu.sh '$WMCLASS ${PAGER:-less}'
@@ -370,8 +358,7 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=git
;;
*senpai*)
elif printf %s "$WMNAME" | grep -qi -w "senpai"; then
CHOICES="
$icon_aru Scroll up ^ 1 ^ sxmo_type -k Prior
$icon_ard Scroll down ^ 1 ^ sxmo_type -k Next
@@ -381,8 +368,7 @@ case "$WMCLASS" in
$icon_usr Toggle Members ^ 0 ^ sxmo_type -k F8
"
WINNAME=senpai
;;
*weechat*)
elif printf %s "$WMNAME" | grep -qi -w "weechat"; then
#weechat
CHOICES="
$icon_msg Hotlist Next ^ 1 ^ sxmo_type -M Alt a
@@ -394,8 +380,7 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=weechat
;;
*" sms "*|*"missed call"*)
elif printf %s "$WMNAME" | grep -qi -w "sms\|missed call"; then
number="$(printf "%s\n" "$WMNAME" | xargs -0 pnc find | tr -d '\n')"
#sms
CHOICES="
@@ -420,8 +405,7 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=phone
;;
*cmus*)
elif printf %s "$WMNAME" | grep -qi -w "cmus"; then
# cmus
# requires `:set set_term_title=false` in cmus to match the application
CHOICES="
@@ -435,29 +419,7 @@ case "$WMCLASS" in
$icon_mnu Terminal menu ^ 0 ^ sxmo_appmenu.sh $WMCLASS
"
WINNAME=cmus
;;
*iamb*)
CHOICES="
$icon_aru Page Up ^ 1 ^ sxmo_type.sh -k Escape -M Ctrl -k b
$icon_tab Toggle Selection ^ 0 ^ sxmo_type.sh -k Escape -M Ctrl -k W m
$icon_ard Page Down ^ 1 ^ sxmo_type.sh -k Escape -M Ctrl -k f
$icon_ret Reply To Message ^ 0 ^ sxmo_type.sh -k Escape :reply -k Return
$icon_tab New Tab ^ 0 ^ sxmo_type.sh -k Escape :tab rooms -k Return
$icon_arl Previous Tab ^ 0 ^ sxmo_type.sh -k Escape :tabp -k Return
$icon_arr Next Tab ^ 0 ^ sxmo_type.sh -k Escape :tabn -k Return
$icon_cls Close Tab ^ 0 ^ sxmo_type.sh -k Escape :tabclose -k Return
$icon_win Split View ^ 0 ^ sxmo_type.sh -k Escape :split -k Return
$icon_win Split View Vertical ^ 0 ^ sxmo_type.sh -k Escape :vsplit -k Return
$icon_msg All Chats ^ 0 ^ sxmo_type.sh -k Escape :chats -k Return
$icon_msg Direct Messages ^ 0 ^ sxmo_type.sh -k Escape :dms -k Return
$icon_grp Rooms ^ 0 ^ sxmo_type.sh -k Escape :rooms -k Return
$icon_glb Spaces ^ 0 ^ sxmo_type.sh -k Escape :spaces -k Return
$icon_sav Download ^ 0 ^ sxmo_type.sh -k Escape :download -k Return
$icon_cls Close View/Quit ^ 0 ^ sxmo_type.sh -k Escape :quit -k Return
"
WINNAME=iamb
;;
*)
else
# Now we fallback to the default terminal menu
case "$WMCLASS" in
*st*)
@@ -519,7 +481,7 @@ case "$WMCLASS" in
WINNAME=Alacritty
;;
esac
esac
fi
;;
*okular*)
# Okular
@@ -574,7 +536,6 @@ case "$WMCLASS" in
# Netsurf
CHOICES="
$icon_flt Pipe URL ^ 0 ^ sxmo_urlhandler.sh
$icon_lnk Enter URL ^ 0 ^ sxmo_type.sh -M Ctrl -k l
$icon_zmi Zoom ^ 1 ^ sxmo_type -M Ctrl -k plus
$icon_zmo Zoom ^ 1 ^ sxmo_type -M Ctrl -k minus
$icon_arl History ^ 1 ^ sxmo_type -M Alt -k Left
@@ -635,26 +596,9 @@ case "$WMCLASS" in
"
WINNAME=Firefox
;;
*krita*)
# Krita
CHOICES="
$icon_fnd Open ^ 0 ^ sxmo_type -M Ctrl o
$icon_sav Save ^ 0 ^ sxmo_type -M Ctrl s
$icon_pst Paste ^ 0 ^ sxmo_type -M Ctrl v
$icon_del Delete ^ 0 ^ sxmo_type -k Delete
$icon_win Select ^ 0 ^ sxmo_type -M Ctrl r
$icon_modem_disabled Deselect ^ 0 ^ sxmo_type -M Ctrl -M Shift a
$icon_wn2 Crop ^ 0 ^ sxmo_type c
$icon_flt Fill ^ 0 ^ sxmo_type f
$icon_modem_connected Gradient ^ 0 ^ sxmo_type g
$icon_dof HSV Adjust ^ 0 ^ sxmo_type -M Ctrl u
$icon_cls Close Image ^ 0 ^ sxmo_type -M Ctrl w
"
WINNAME=Krita
;;
*vimb*)
CHOICES="
$icon_glb Navigate ^ 0 ^ sxmo_type -k Escape o
$icon_glb Navigate ^ 0 ^ sxmo_type -k Escape o && sxmo_keyboard.sh open
$icon_zmi Zoom ^ 1 ^ sxmo_type -k Escape zi
$icon_zmo Zoom ^ 1 ^ sxmo_type -k Escape zo
$icon_arl History ^ 1 ^ sxmo_type -M Ctrl o
@@ -671,12 +615,12 @@ case "$WMCLASS" in
$icon_cls Close Tab ^ 0 ^ sxmo_type -M Ctrl w
$icon_bok Open Bookmarks ^ 0 ^ sxmo_type -M Ctrl b
$icon_pls Add Bookmark ^ 0 ^ sxmo_type -M Ctrl d
$icon_edt Edit Bookmarks ^ 0 ^ sxmo_terminal.sh $EDITOR ~/.local/share/geopard/bookmarks.gemini
$icon_edt Edit Bookmarks ^ 0 ^ sxmo_keyboard.sh open && sxmo_terminal.sh $EDITOR ~/.local/share/geopard/bookmarks.gemini
$icon_zmi Increase Font Size ^ 1 ^ sxmo_type -M Ctrl -k plus
$icon_zmo Decrease Font Size ^ 1 ^ sxmo_type -M Ctrl -k minus
$icon_arl History Back ^ 1 ^ sxmo_type -M Alt -k Left
$icon_arr History Forward ^ 1 ^ sxmo_type -M Alt -k Right
$icon_fnd URL Bar ^ 0 ^ sxmo_type -k F6
$icon_fnd URL Bar ^ 0 ^ sxmo_keyboard.sh open && sxmo_type -k F6
$icon_rld Refresh ^ 0 ^ sxmo_type -k F6 -k Return
"
WINNAME=Geopard
@@ -702,7 +646,7 @@ case "$WMCLASS" in
$icon_zmi Zoom in ^ 1 ^ sxmo_type -M ctrl =
$icon_zmo Zoom out ^ 1 ^ sxmo_type -M ctrl -k minus
$icon_fnd Explore POI ^ 0 ^ sxmo_type -M ctrl -M Shift F
$icon_fnd Search ^ 0 ^ sxmo_type -M ctrl f
$icon_fnd Search ^ 0 ^ sxmo_type -M ctrl f && sxmo_keyboard.sh open
$icon_lst Show last results ^ 0 ^ sxmo_type -M ctrl r
$icon_map Toggle route planner ^ 0 ^ sxmo_type -M ctrl d
$icon_gps Show current location ^ 0 ^ sxmo_type -M ctrl l
@@ -727,110 +671,26 @@ case "$WMCLASS" in
"
WINNAME=Maps
;;
*badwolf*)
# Badwolf Browser
CHOICES="
$icon_tab New Tab ^ 0 ^ sxmo_type -M Ctrl -k t
$icon_cls Close Tab ^ 0 ^ sxmo_type -M Alt -k d
$icon_fnd Reset Zoom ^ 0 ^ sxmo_type -M Ctrl -k 0
$icon_arr History ^ 1 ^ sxmo_type -M Ctrl ]
$icon_arl History ^ 1 ^ sxmo_type -M Ctrl [
$icon_arr Next Tab ^ 1 ^ sxmo_type -M Alt -k Right
$icon_arl Previous Tab ^ 1 ^ sxmo_type -M Alt -k Left
$icon_rld Refresh ^ 0 ^ sxmo_type -M Shift -M Ctrl -k r
$icon_fnd Search ^ 0 ^ sxmo_type -M Shift -M Ctrl -k f
$icon_arr Next (Search) ^ 0 ^ sxmo_type -M Shift -M Ctrl -k g
$icon_arl Previous (Search) ^ 0 ^ sxmo_type -M Shift -M Ctrl -M Shift -k g
$icon_flt URL Bar ^ 0 ^ sxmo_type -M Shift -M Ctrl l
$icon_fnd Open Web Inspector ^ 0 ^ sxmo_type -k F12
"
WINNAME=Badwolf
;;
*acme*)
# Acme
CHOICES="
$icon_mse 2 (Right) [2s delay] ^ 0 ^ sleep 2 && xdotool click 3
$icon_mse 3 (Middle) [2s delay] ^ 0 ^ sleep 2 && xdotool click 2
$icon_itm Autocomplete ^ 0 ^ sxmo_type.sh -M Ctrl -k f
$icon_exp Select Last Typed Text ^ 0 ^ sxmo_type.sh -M Escape
$icon_del Delete To Start Of Line ^ 0 ^ sxmo_type.sh -M Ctrl -k U
$icon_arl Move To Start Of Line ^ 0 ^ sxmo_type.sh -M Ctrl -k A
$icon_arr Move To End Of Line ^ 0 ^ sxmo_type.sh -M Ctrl -k E
"
WINNAME=Acme
;;
*mupdf*)
# Mupdf
CHOICES="
$icon_nxt Next Page ^ 0 ^ sxmo_type -k Space
$icon_prv Previous Page ^ 0 ^ sxmo_type -k b
$icon_chk Mark Page ^ 0 ^ sxmo_type -k m
$icon_ret Pop To Last Mark ^ 0 ^ sxmo_type -k t
$icon_zmi Zoom In ^ 1 ^ sxmo_type -k +
$icon_zmo Zoom Out ^ 1 ^ sxmo_type -k -
$icon_fnd Fit Width ^ 0 ^ sxmo_type -k W
$icon_fnd Fit Height ^ 0 ^ sxmo_type -k H
$icon_fnd Zoom To Fit ^ 0 ^ sxmo_type -k Z
$icon_fnd Reset Zoom ^ 0 ^ sxmo_type -k z
$icon_rol Rotate Counterclockwise ^ 0 ^ sxmo_type -k [
$icon_ror Rotate Clockwise ^ 0 ^ sxmo_type -k ]
$icon_fnd Search ^ 0 ^ sxmo_type -k /
"
WINNAME=Mupdf
;;
*tabbed*)
# Tabbed
CHOICES="
$icon_tab New Tab ^ 0 ^ sxmo_type.sh -M Ctrl -M Shift -M Enter
$icon_arl Previous Tab ^ 1 ^ sxmo_type.sh -M Ctrl -M Shift -k h
$icon_arr Next Tab ^ 1 ^ sxmo_type.sh -M Ctrl -M Shift -k l
$icon_arl Move Tab Left ^ 1 ^ sxmo_type.sh -M Ctrl -M Shift -k j
$icon_arr Move Tab Right ^ 1 ^ sxmo_type.sh -M Ctrl -M Shift -k k
$icon_mnu Menu Prompt ^ 0 ^ sxmo_type.sh -M Ctrl -k U0060
$icon_cls Close Tab ^ 0 ^ sxmo_type.sh -M Ctrl -k q
"
WINNAME=Tabbed
;;
*links*)
# Links Browser
CHOICES="
$icon_mnu Menu ^ 0 ^ sxmo_type.sh -k Escape
$icon_ret Follow Link ^ 0 ^ sxmo_type.sh -k Enter
$icon_arl History ^ 1 ^ sxmo_type.sh -k z
$icon_arr History ^ 1 ^ sxmo_type.sh -k x
$icon_glb Enter URL ^ 0 ^ sxmo_type.sh -k g
$icon_glb Edit Current URL ^ 0 ^ sxmo_type.sh -k G
$icon_glb View Highlighted URL ^ 0 ^ sxmo_type.sh -M Ctrl -k g
$icon_cam Toggle Images ^ 0 ^ sxmo_type.sh -k U002A
$icon_aru Scroll Up ^ 1 ^ sxmo_type.sh -k p
$icon_ard Scroll Down ^ 1 ^ sxmo_type.sh -k l
$icon_arl Scroll Left ^ 1 ^ sxmo_type.sh -k U005B
$icon_arr Scroll Right ^ 1 ^ sxmo_type.sh -k U005D
"
WINNAME=Links
;;
*)
# Default system menu (no matches)
CHOICES="
$icon_grd Scripts ^ 0 ^ sxmo_appmenu.sh scripts
$icon_grd Apps ^ 0 ^ sxmo_appmenu.sh applications
$([ "$SXMO_MENU" = "wofi" ] && echo "$icon_grd All Apps ^ 0 ^ wofi -O alphabetical -i --show drun")
$([ "$SXMO_MENU" != "wofi" ] && command -v j4-dmenu-desktop > /dev/null && echo "$icon_grd All Apps ^ 0 ^ j4-dmenu-desktop --dmenu=sxmo_dmenu.sh --term=sxmo_terminal.sh")
$icon_grd Binaries ^ 0 ^ sxmo_brun.sh
$icon_dir Files ^ 0 ^ sxmo_files.sh
$icon_phn Dialer ^ 0 ^ sxmo_modemdial.sh
$icon_msg Texts ^ 0 ^ sxmo_modemtext.sh
$icon_usr Contacts ^ 0 ^ sxmo_contactmenu.sh
$(
rfkill list bluetooth -no ID,SOFT,HARD | grep -vq " blocked" &&
rfkill list bluetooth | grep -q "yes" ||
printf %b "$icon_bth Bluetooth ^ 1 ^ sxmo_bluetoothmenu.sh"
)
$(command -v megapixels >/dev/null && echo "$icon_cam Camera ^ 0 ^ GDK_SCALE=2 megapixels")
$(
if brightness="$(brightnessctl -d "white:flash" get)"; then
if [ -z "$SXMO_DISABLE_LEDS" ]; then
printf "%s Flashlight " "$icon_fll"
[ "$brightness" -gt 0 ] &&
printf %b "$icon_ton" || printf %b "$icon_tof";
sxmo_led.sh get white | grep -vq ^100$ &&
printf %b "$icon_tof" || printf %b "$icon_ton";
printf %b "^ 1 ^ sxmo_flashtoggle.sh"
fi
)
@@ -839,7 +699,6 @@ case "$WMCLASS" in
$icon_phn Modem ^ 0 ^ sxmo_appmenu.sh modem
$icon_win Windows ^ 0 ^ sxmo_wmmenu.sh
$icon_cfg Config ^ 0 ^ sxmo_appmenu.sh config
$icon_inf Help ^ 0 ^ sxmo_terminal.sh man sxmo
$icon_pwr Power ^ 0 ^ sxmo_appmenu.sh power
"
WINNAME=Sys

View File

@@ -83,13 +83,11 @@ icon_mod="" # modem
icon_mov="󰁁"
icon_mse="󰍽" # computer mouse (🖱️)
icon_msg="󰍦" #text
icon_mtr="󰟚" # metronome
icon_mus="󰎈"
icon_mut="" #mute
icon_mvi="󰎁" #movie
icon_net="󰀂"
icon_nto="" #no touch
icon_nvi="" # neovim
icon_nxt="" #next
icon_out="󰍃" #logout
icon_pau=""
@@ -109,10 +107,8 @@ icon_rol="" #rotate left
icon_ror="" #rotate right
icon_rss=""
icon_sav="󰆓" #save
icon_scn="󰚫" #scanner
icon_sfl="" #shuffle, random
icon_shr="󰁄" #shrink
icon_sim="󰒧" # sim card
icon_snd="" #send
icon_spk="" #speaker
icon_spl=""

View File

@@ -3,8 +3,7 @@
# Copyright 2022 Sxmo Contributors
# This script handles input actions, it is called by lisgd for gestures
# and by dwm for button presses. Gestures are tied to actions in
# sxmo_hook_lisgdstart.sh .
# and by dwm for button presses
ACTION="$1"
@@ -20,9 +19,9 @@ XPROPOUT="$(sxmo_wm.sh focusedwindow)"
WMCLASS="$(printf %s "$XPROPOUT" | grep app: | cut -d" " -f2- | tr '[:upper:]' '[:lower:]')"
WMNAME="$(printf %s "$XPROPOUT" | grep title: | cut -d" " -f2- | tr '[:upper:]' '[:lower:]')"
sxmo_debug "STATE: $(sxmo_state.sh get) ACTION: $ACTION WMCLASS: $WMCLASS WMNAME: $WMNAME"
sxmo_debug "STATE: $(cat "$SXMO_STATE") ACTION: $ACTION WMCLASS: $WMCLASS WMNAME: $WMNAME"
if sxmo_state.sh is_locked; then
if ! grep -q unlock "$SXMO_STATE"; then
case "$WMNAME" in # Handle programs
*"epy"*|*"epr"*)
case "$ACTION" in
@@ -98,48 +97,6 @@ case "$WMCLASS" in
;;
esac
;;
*"acme"*)
case "$ACTION" in
"volup_one")
xdotool click 3
exit 0
;;
"voldown_one")
xdotool click 2
exit 0
;;
esac
;;
*"links"*)
case "$ACTION" in
# you're probably dragging the scrollbar
*"uprightedge") exit 0 ;;
*"downrightedge") exit 0 ;;
*"onedown")
sxmo_type.sh -M Ctrl -M Shift -k b
exit 0
;;
*"oneup")
sxmo_type.sh -M Ctrl -M Shift -k f
exit 0
;;
esac
;;
*"netsurf"*)
case "$ACTION" in
# you're probably dragging the scrollbar
*"uprightedge") exit 0 ;;
*"downrightedge") exit 0 ;;
*"onedown")
sxmo_type.sh -k Page_Up
exit 0
;;
*"oneup")
sxmo_type.sh -k Page_Down
exit 0
;;
esac
;;
*"foot"*|*"st"*|*"vte"*|"terminal") # Terminals
case "$WMCLASS" in # Handle programs without touch support
*"st"*)
@@ -361,11 +318,7 @@ case "$ACTION" in
exit 0
;;
"voldown_one")
if [ -n "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then
sxmo_killwindow.sh
else
sxmo_keyboard.sh toggle
fi
exit
;;
"voldown_two")
@@ -421,19 +374,11 @@ case "$ACTION" in
exit 0
;;
"upbottomedge")
if [ -n "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then
sxmo_terminal.sh
else
sxmo_keyboard.sh open
fi
exit 0
;;
"downbottomedge")
if [ -n "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then
sxmo_killwindow.sh
else
sxmo_keyboard.sh close
fi
exit 0
;;
"downtopedge")

View File

@@ -1,12 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# For use with peanutbutter (peanutbutter --font Sxmo --statuscommand sxmo_hook_lockstatusbar.sh)
# This filters out the last component (which is usually the time and is already displayed more prominently
# make sure status bar icons are suited for peanutbutter
sxmo_hook_statusbar.sh state_change
# obtain status output to pass to peanutbutter (this keeps running and updating to stdout)
exec sxmo_status_watch.sh -o pango

View File

@@ -2,10 +2,6 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# Runs when a notification arrives,
# Arguments:
# $1 - The notification file which contains the notification text.
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh

View File

@@ -47,14 +47,6 @@ vibrate() {
done &
}
# SILENT MODE
if [ -f "$XDG_CONFIG_HOME"/sxmo/.busy ]; then
end="$(cat "$XDG_CONFIG_HOME"/sxmo/.busy)"
if [ -z "$end" ] || [ "$(date +%s)" -lt "$end" ]; then
exit
fi
fi
# RING & VIBRATE MODE (DEFAULT)
if [ ! -f "$XDG_CONFIG_HOME"/sxmo/.noring ] && [ ! -f "$XDG_CONFIG_HOME"/sxmo/.novibrate ]; then
sxmo_log "RING AND VIBRATE"

View File

@@ -22,10 +22,7 @@ sxmo_led.sh blink red blue &
sxmo_wm.sh dpms on
sxmo_wm.sh inputevent touchscreen off
if [ ! -e "$XDG_CACHE_HOME"/sxmo/sxmo.nosuspend ]; then
sxmo_jobs.sh start periodic_blink \
sxmo_run_periodically.sh -w 2 -- sxmo_led.sh blink red blue
fi
sxmo_jobs.sh start periodic_blink sxmo_run_periodically.sh - 2 sxmo_led.sh blink red blue
case "$SXMO_WM" in
dwm)
@@ -40,11 +37,3 @@ esac
sxmo_jobs.sh stop idle_locker
wait
case "$SXMO_WM" in
sway)
if command -v peanutbutter > /dev/null; then
peanutbutter --font Sxmo --statuscommand sxmo_hook_lockstatusbar.sh && sxmo_hook_statusbar.sh state_change &
fi
;;
esac

View File

@@ -17,17 +17,7 @@
. sxmo_common.sh
# do nothing if active call
if sxmo_modemcall.sh list_active_calls | grep -q active; then
exit
fi
# do nothing if silent mode
if [ -f "$XDG_CONFIG_HOME"/sxmo/.busy ]; then
end="$(cat "$XDG_CONFIG_HOME"/sxmo/.busy)"
if [ -z "$end" ] || [ "$(date +%s)" -lt "$end" ]; then
exit
fi
fi
if ! sxmo_modemcall.sh list_active_calls | grep -q active; then
if [ ! -f "$XDG_CONFIG_HOME"/sxmo/.noring ]; then
mpv --no-resume-playback --quiet --no-video "$SXMO_TEXTSOUND" >> /dev/null 2>&1 &
@@ -38,3 +28,5 @@ if [ ! -f "$XDG_CONFIG_HOME"/sxmo/.novibrate ]; then
fi
wait
fi

View File

@@ -2,8 +2,6 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# Runs upon system start and starts various background services
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
@@ -53,10 +51,10 @@ case "$SXMO_WM" in
superctl start sxmo_wob
superctl start sxmo_menumode_toggler
superctl start bonsaid
swaymsg output '*' bg "$SXMO_BG_IMG" fill
;;
dwm)
superctl start dunst
superctl start sxmo_xob
# Auto hide cursor with touchscreen, Show it with a mouse
if command -v "unclutter-xfixes" > /dev/null; then
@@ -71,6 +69,7 @@ case "$SXMO_WM" in
superctl start sxmo-x11-status
superctl start bonsaid
[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary
feh --bg-fill "$SXMO_BG_IMG"
;;
esac
@@ -97,9 +96,6 @@ if [ -z "$SXMO_NO_MODEM" ] && command -v ModemManager > /dev/null; then
sxmo_wakelock.sh lock sxmo_modem_warming_up 120s
fi
# Start the desktop wallpaper
superctl start sxmo_bg
# Start the desktop widget (e.g. clock)
superctl start sxmo_conky

View File

@@ -17,14 +17,9 @@
# right and "variable" icons (that come and go) on the left.
set_time() {
if pidof peanutbutter > /dev/null; then
#peanutbutter already features a clock, no need for one in the icon bar
sxmobar -d time
else
date "+${SXMO_STATUS_DATE_FORMAT:-%H:%M}" | while read -r date; do
sxmobar -a time 99 "$date"
done
fi
}
set_state() {
@@ -37,13 +32,8 @@ set_state() {
return
fi
if command -v peanutbutter > /dev/null; then
# no need for a state icon in this (default) scenario, the state will be obvious, either peanutbutter is on or it isn't
sxmobar -d state
return
fi
case "$(sxmo_state.sh get)" in
STATE_LABEL="$(cat "$SXMO_STATE")"
case "$STATE_LABEL" in
screenoff)
sxmobar -a -e bold -f red state 90 "$icon_state_screenoff" # filled circle
;;
@@ -189,10 +179,8 @@ set_modem() {
;;
esac
if [ "$MODEMSTATE" != failed ] && [ "$MODEMSTATE" != unknown ]; then
sxmobar -a -f "$fgcolor" -b "$bgcolor" -t "$style" \
modem-tech 11 "$MODEMTECHCMP"
fi
MODEMSIGNALCMP="$icon_modem_signal_0"
bgcolor=default
@@ -212,10 +200,8 @@ set_modem() {
;;
esac
if [ "$MODEMSTATE" != failed ] && [ "$MODEMSTATE" != unknown ]; then
sxmobar -a -f "$fgcolor" -b "$bgcolor" -t "$style" \
modem-signal 12 "$MODEMSIGNALCMP"
fi
}
# $1 = type (wifi, tun)
@@ -429,14 +415,6 @@ set_volume() {
fi
}
set_notch() {
if [ -n "$SXMO_NOTCH" ] && ! pidof peanutbutter > /dev/null; then
sxmobar -a notch "${SXMO_NOTCH_PRIO:-29}" "$SXMO_NOTCH"
else
sxmobar -d notch
fi
}
sxmo_debug "$@"
case "$1" in
network)
@@ -447,7 +425,7 @@ case "$1" in
shift
set_battery "$@"
;;
time|modem|volume|state|notifications|notch)
time|modem|volume|state|notifications)
set_"$1"
;;
periodics|state_change) # 55 s loop and screenlock triggers
@@ -455,7 +433,6 @@ case "$1" in
if [ -z "$SXMO_NO_MODEM" ]; then
set_modem
fi
set_notch
set_state
set_network wifi wlan0
;;
@@ -470,7 +447,6 @@ case "$1" in
fi
set_state
set_notifications
set_notch
set_network wifi wlan0
;;
*)

View File

@@ -1,6 +1,6 @@
#!/bin/sh
# Runs after wm has been stopped., useful for cleanup
# Runs after wm has been stopped.
# clean up misc. stale files (if any)
rm -rf "$XDG_RUNTIME_DIR"/sxmo*

View File

@@ -33,7 +33,7 @@ mkcontactssedcmd() {
TODAY="$(date +%F)"
YESTERDAY="$(date -d "- 1 day" +%F)"
TWO_DAYS="$(date -d "- 2 day" +%F)"
DATESEDCMD="s/ at ${TODAY}T/today at /; s/ at ${YESTERDAY}T/yesterday at /; s/ at ${TWO_DAYS}T/two days ago at /; s/[-+][0-9][0-9][0-9][0-9]://; s/\(-[0-9][0-9]\)T\([0-9][0-9]\)/\1 \2/;"
DATESEDCMD="s/at.*${TODAY}T/today at /; s/at.*${YESTERDAY}T/yesterday at /; s/at.*${TWO_DAYS}T/two days ago at /; s/[-+][0-9][0-9][0-9][0-9]://; s/\(-[0-9][0-9]\)T\([0-9][0-9]\)/\1 \2/;"
# TODO
#ALIGNSEDCMD="s/^Sent/<right align>/;s/^Received/<left align>/;"

View File

@@ -1,28 +0,0 @@
#!/bin/sh -e
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
# This script is executed once, and must output the wallpaper to display
installed_wallpapers() {
xdg_data_path wallpapers 0 "\0" | xargs -r0I{} find "{}" -name "$SXMO_OS.*"
}
sxmo_wallpaper() {
xdg_data_path sxmo/background.jpg
}
all_wallpapers() {
installed_wallpapers
sxmo_wallpaper
}
if [ -n "$SXMO_BG_IMG" ]; then
printf "%s" "$SXMO_BG_IMG"
exit
fi
all_wallpapers | head -n1

View File

@@ -0,0 +1 @@
./three_button_touchscreen

View File

@@ -0,0 +1 @@
./three_button_touchscreen

View File

@@ -0,0 +1 @@
./three_button_touchscreen

View File

@@ -0,0 +1 @@
./three_button_touchscreen

View File

@@ -4,7 +4,7 @@ permit nopass :wheel as root cmd busybox args reboot
permit nopass :wheel as root cmd poweroff
permit nopass :wheel as root cmd reboot
permit nopass :wheel as root cmd sxmo_wifitoggle.sh
permit nopass setenv { SXMO_OS } :wheel as root cmd sxmo_bluetoothtoggle.sh
permit nopass :wheel as root cmd sxmo_bluetoothtoggle.sh
permit nopass :wheel as root cmd rc-service args bluetooth restart
permit nopass :wheel as root cmd systemctl args restart bluetooth
permit nopass :wheel as root cmd tinydm-set-session
@@ -20,5 +20,3 @@ permit nopass :wheel as root cmd rtcwake
permit nopass :wheel as root cmd tee args -a /sys/power/wake_lock
permit nopass :wheel as root cmd tee args -a /sys/power/wake_unlock
permit nopass :wheel as root cmd tee args /sys/power/wakeup_count
permit nopass :wheel as root cmd rc-service args hexagonrpcd-adsp-sensorspd stop
permit nopass :wheel as root cmd systemctl args stop hexagonrpcd-adsp-sensorspd

View File

@@ -1,6 +0,0 @@
polkit.addRule(function(action, subject) {
if (action.id == "net.hadess.SensorProxy.claim-sensor" &&
subject.isInGroup("plugdev")) {
return polkit.Result.YES;
}
});

View File

@@ -48,11 +48,6 @@ _sxmo_find_runtime_dir() {
fi
done
if command -v mkrundir > /dev/null 2>&1; then
mkrundir
return
fi
# Fallback to a shared memory location
printf "/dev/shm/user/%s" "$(id -u)"
}

View File

@@ -1,7 +0,0 @@
[Unit]
Description=The Sxmo wallpaper as a service
[Service]
Type=simple
Restart=always
ExecStart=sxmo_bg.sh fill

View File

@@ -4,4 +4,4 @@ Description=display notifications popup messages
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/sxmo_notifs.sh monitor
ExecStart=/usr/bin/sxmo_notificationmonitor.sh

View File

@@ -4,4 +4,4 @@ Description=A lightweight overlay volume/backlight/progress/anything bar for Way
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/sxmo_ob.sh wob
ExecStart=/usr/bin/sxmo_wob.sh

View File

@@ -1,7 +0,0 @@
[Unit]
Description=A lightweight overlay volume/backlight/progress/anything bar for X11
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/sxmo_ob.sh xob

View File

@@ -8,9 +8,3 @@ ACTION=="add", SUBSYSTEM=="iio", TEST=="in_proximity_raw" RUN+="/bin/chmod g+rw
## Read device to monitor event
ACTION=="add", SUBSYSTEM=="iio", TEST=="in_proximity_raw" RUN+="/bin/chgrp input $devnode"
ACTION=="add", SUBSYSTEM=="iio", TEST=="in_proximity_raw" RUN+="/bin/chmod g+r $devnode"
# LEDs
ACTION=="add", SUBSYSTEM=="leds", RUN+="/bin/chgrp video /sys/class/leds/%k/brightness"
ACTION=="add", SUBSYSTEM=="leds", RUN+="/bin/chmod g+w /sys/class/leds/%k/brightness"
ACTION=="add", SUBSYSTEM=="leds", RUN+="/bin/chgrp video /sys/class/leds/%k/multi_intensity"
ACTION=="add", SUBSYSTEM=="leds", RUN+="/bin/chmod g+w /sys/class/leds/%k/multi_intensity"

File diff suppressed because it is too large Load Diff

View File

@@ -6,18 +6,18 @@ sxmo_contact.sh - a simple contacts manager
# SYNOPSIS
*sxmo_contacts.sh* [options]
sxmo_contacts.sh allows you to store and lookup contacts in a variety of ways.
# DESCRIPTION
Allows you to store and lookup contacts in a variety of ways.
TODO
# OPTIONS
_string_ (default)
If _string_ is given, search the contact book for _string_. The output
will be CONTACTNAME: PHONENUMBER for each hit. Note it uses grep so
multiple hits Are possible.
multiple hits are possible.
If no argument is given, then return *all* contacts from the contact
book and also every number that has ever texted or called you.
The output will be CONTACTNAME: PHONENUMBER (if in the contact book) or
@@ -46,16 +46,19 @@ _string_ (default)
*--me*
Return the phonenumber associated with the *Me* entry in contact book.
*--name-or-number* _phonenumber_
*--name-or-nuber* _phonenumber_
Return the contact name (if present) or _phone number_ (if not).
*--name* _phonenumber_
Return the contact name (if present) or *???* (if not)
# ENVIRONMENT
# EXIT STATUS
*SXMO_CONTACTFILE*
a TSV file containing contacts (~/.config/sxmo/contacts.tsv by default)
# RETURN VALUE
# ERRORS
# ENVIRONMENT
# FILES
@@ -65,10 +68,16 @@ number that has ever texted or called you.
~/.config/sxmo/contacts.tsv - a TSV file containing contacts in the format
PHONENUMBER tab CONTACTNAME
# NOTES
# BUGS
# EXAMPLES
# AUTHORS
# REPORTING BUGS
# COPYRIGHT
GNU Affero General Public License v3
# SEE ALSO
_sxmo_(7), c.f. CONTACTS section

View File

@@ -1,17 +0,0 @@
sxmo_files.sh(1)
# NAME
sxmo_files.sh
# SYNOPSIS
*sxmo_files.sh*
# DESCRIPTION
A menu-based file manager for Sxmo. Invokes _sxmo_open.sh_(1) to open files.
# SEE ALSO
_sxmo_(7)

View File

@@ -1,69 +1,34 @@
sxmo_migrate.sh(1)
*Update migrations*
# NAME
While developing sxmo, we will regularly update certain configuration
files such as the xinit/sway template, the hooks or whatever. These
files are typically a mixture of changes by us and customizations by
the user. This mixture gives the user maximum flexibility to adapt Sxmo
to their liking. However, when we update such files, the challenge is
to ensure that user modifications can be easily merged back in again.
Moreover, we must ensure the system is never in a broken state because
of outdated configurations and version mismatches.
sxmo_migrate.sh - migration tool for sxmo
Whenever your configuration files are out-of-date when starting Sxmo,
they will be moved aside (i.e. renamed with *.needs-revision* extension)
and the default configuration will take its place. A red notification
will pop up telling you have configuration files that need to be
migrated. This migration is done by running a script named
_sxmo_migrate_(1). This script can simply be launched from the
configuration menu or via ssh (recommended).
It first shows the differences between your configuration and the new
default, and allows you to edit and apply your configuration accordingly.
_sxmo_migrate_(1) use *$DIFFTOOL* to help you merge your changes. By default
$DIFFTOOL is set to *vimdiff*.
# SYNOPSIS
If you have any pending migrations, always make sure to complete the
migration process before making any new changes to your configuration.
It is also recommended to keep your configuration under version control
(e.g. git).
*sxmo_migrate.sh* [subcommands...]
*Techical details*:
# SUBCOMMANDS
*reset*
Reverts *all* your configuration files and hooks to the default. Be careful with this one.
This is intended as a last resort if you end up with a broken system.
All your configuration files will moved out of the way and
flagged for migration then.
*state*
Reports whether there are any configuration files/hooks pending migration.
*sync*
Triggers a check of the versions of your configuration files and hooks.
It runs automatically when Sxmo starts.
*sync state*
Use this combination after you just finished a migration but didn't restart the
system yet
# DESCRIPTION
While developing sxmo, we will regularly update certain configuration files
such as the xinit/sway template, the hooks or whatever. These files are
typically a mixture of changes by us and customizations by the user. This
mixture gives the user maximum flexibility to adapt Sxmo to their liking.
However, when we update such files, the challenge is to ensure that user
modifications can be easily merged back in again. Moreover, we must ensure the
system is never in a broken state because of outdated configurations and
version mismatches.
Whenever your configuration files are out-of-date when starting Sxmo, they will
be moved aside (i.e. renamed with *.needs-revision* extension) and the default
configuration will take its place. This ensures that the system always remains
functional and no conflicts should arise. A red notification will pop up
telling you have configuration files that need to be migrated.
The migration is done by running a script named _sxmo_migrate_(1). This script
can simply be launched from the configuration menu or via ssh (recommended). It
first shows the differences between your configuration and the new default, and
allows you to edit and apply your configuration accordingly. If you have
_delta_(1) or _colordiff_(1) installed, they will be used to show the diff. In the
edit stage, _sxmo_migrate_(1) uses *$DIFFTOOL* to help you merge your changes.
By default $DIFFTOOL is set to *vimdiff*. If not available, your regular
*$EDITOR* will be used.
If you have any pending migrations, always make sure to complete the migration
process before making any new changes to your configuration. It is also
recommended to keep your configuration under version control (e.g. git).
*Note:* The order of the diff arguments can be changed by setting environment
variable *$SXMO_MIGRATE_ORDER* to "user:system", instead of the default
"system:user". It can also be toggled at runtime.
# TECHNICAL DETAILS
Sxmo uses explicitly versioned configuration files, meaning
Sxmo (since 1.8.1) uses explicitly versioned configuration files, meaning
that they each carry a simple version hash unique to the file.
This version hash is expressed in a comment in the file itself, such as:
@@ -73,29 +38,28 @@ This version hash is expressed in a comment in the file itself, such as:
You should *only* update this version hash when *sxmo_migrate.sh*
prompts you to do so by showing a diff of a newer configversion hash.
This information is used to determine whether your custom configuration
is up-to-date with the system-supplied defaults.
## RESOLVING SYSTEM CONFIGURATIONS ON SYSTEM UPGRADE AND MAKE
If you want to see what files are disabled and need migration, run
*sxmo_migrate.sh state*, or run *sxmo_migrate.sh sync state* if
you just performed an upgrade and haven't restarted yet. If you want to
revert *all* your configuration files to the default, then you can
run *sxmo_migrate.sh reset*. This is usually a last resort if you
end up with a broken system and can be considered a kind of factory
reset, all your configuration files will moved out of the way and
flagged for migration then.
_apk_(1), on postmarketOS, will install new configs as *.apk-new* on upgrades if you
have modified the original config in */etc*. Moreover, when hacking on Sxmo,
you will often run *make install* and this may _modify_ a config in */etc* from
apk's perspective. You can merge apk's config changes by running *doas
update-conf*. You can also run *apk audit* to list all the files that have
changed from what apk originally installed.
The process that checks the versions of your configuration files is
*sxmo_migrate.sh sync*, it runs automatically when Sxmo starts.
# ENVIRONMENT
*Resolving system configs on system upgrade and make*
_sxmo_migrate_(1) read the following environment variables:
Apk will install new configs as
*.apk-new* on upgrades if you have modified the original config in */etc*.
Moreover, when hacking on Sxmo, you will often run `make install`and this may "modify"
a config in /etc from apk's perspective.
You can merge apk's config changes by running `doas update-conf`. You can also run `apk audit`
to list all the files that have changed from what apk originally installed.
*DIFFTOOL*
The diff tool to use for *editing* and resolving migrations (not for display).
SEE ALSO: _sxmo_migrate_(1)
*SXMO_MIGRATE_ORDER*
Can be set to "user:system" or "system:user" (default). Determines the order
in which arguments are passed to diff and therefore how results are colored.
# SEE ALSO
_sxmo_(7)

View File

View File

@@ -1,33 +0,0 @@
sxmo_wakelock.sh(1)
# NAME
sxmo_wakelock.sh - Sets or remove wakelocks
# SYNOPSIS
*sxmo_wakelock.sh* [subcommand]
# DESCRIPTION
This script sets or removes a wakelock, a wakelock tells the kernel to ensure a device is awake at a particular time.
# SUBCOMMNANDS
*isenabled*
Indicates whether a wake lock funcionality is available. Exit code 0 means it is, non-zero means it is not.
*lock* <lock-name> <DURATION|nanosec|infinite>
Sets a wakelock, *DURATION* is be an integer with suffix ms (milliseconds),
s (seconds) ,h (hours), mn (minutes), or an integer in nanoseconds if no
unit was provided. It may also be the string "infinite".
*unlock* <lock-name>
Removes a wakelock
*run* <command>
Spawn a command and set set a wakelock for its entire duration.
# SEE ALSO
_sxmo_(7)

View File

View File

@@ -1,70 +0,0 @@
#include <errno.h> // error handling
#include <stdint.h> // uint64_t type
#include <stdio.h> // dprintf
#include <stdlib.h> // strtol, exit
#include <string.h> // strerror, strcmp
#include <sys/timerfd.h> // timers
#include <unistd.h> // read
static void error(char *message, int err) {
dprintf(2, "%s: %s\n", message, strerror(err));
exit(1);
}
static void usage(char *cmd, char *msg) {
dprintf(2, "Usage: %s [-c <clock-name>] <seconds>\n", cmd);
dprintf(2, "%s\n", msg);
exit(1);
}
int main(int argc, char **argv) {
uint64_t buf;
long duration = -1;
int time_fd;
int clockid = CLOCK_REALTIME;
struct itimerspec time = {
.it_value = { .tv_sec = 0, .tv_nsec = 0 },
.it_interval = { .tv_sec = 0, .tv_nsec = 0 }
};
for (int i = 1; i < argc; i += 1) {
if (0 == strcmp(argv[i], "-c")) {
if (argc <= i + 1) {
usage(argv[0], "You must pass a clock name.");
}
if (0 == strcmp(argv[i+1], "realtime")) {
clockid = CLOCK_REALTIME;
} else if (0 == strcmp(argv[i+1], "monotonic")) {
clockid = CLOCK_MONOTONIC;
} else if (0 == strcmp(argv[i+1], "boottime")) {
clockid = CLOCK_BOOTTIME;
} else if (0 == strcmp(argv[i+1], "realtime_alarm")) {
clockid = CLOCK_REALTIME_ALARM;
} else if (0 == strcmp(argv[i+1], "boottime_alarm")) {
clockid = CLOCK_BOOTTIME_ALARM;
} else {
usage(argv[0], "Unknown clock name.");
}
i += 1;
continue;
}
duration = strtol(argv[i], NULL, 0);;
}
if (duration <= 0) {
usage(argv[0], "You must pass a duration in second.");
}
// Setup timer
if ((time_fd = timerfd_create(clockid, TFD_CLOEXEC)) == -1)
error("Failed to create timerfd", errno);
time.it_value.tv_sec = duration;
if (timerfd_settime(time_fd, 0, &time, NULL) == -1)
error("Failed to set timer",errno);
// Wait for timer
read(time_fd, &buf, sizeof(uint64_t));
}

View File

@@ -1,584 +0,0 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2024 Aren Moynihan
// Copyright 2024 Sxmo Contributors
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
// for tests
#include <assert.h>
#define BIT(n) 1<<n
// Logging functions
#define info(...) ({ if (verbose) fprintf(stderr, __VA_ARGS__); })
#define error(format, ...) ({ if (!quiet) fprintf(stderr, format "\n", ## __VA_ARGS__); })
static bool quiet = false;
static bool verbose = false;
static char *led_dir = "/sys/class/leds";
enum color {
COLOR_RED,
COLOR_GREEN,
COLOR_BLUE,
COLOR_MAX,
};
typedef union {
double colors[COLOR_MAX];
struct {
double red;
double green;
double blue;
};
} led_state;
struct led_handle {
int brightness;
int max_brightness;
};
void close_single_led(struct led_handle *led) {
if (led->brightness > 0)
close(led->brightness);
}
struct multicolor_handle {
enum color color_ids[3];
// file descriptors, names match sysfs
FILE *brightness;
FILE *multi_intensity;
int max_brightness;
};
enum led_type {
LED_GROUP,
LED_MULTICOLOR,
};
struct status_handle {
enum led_type type;
union {
struct multicolor_handle multicolor;
struct led_handle group[COLOR_MAX];
};
};
struct timespec delay_length = {
.tv_sec = 0,
// 150ms
.tv_nsec = 150000000,
};
// see include/dt-bindings/leds/common.h in linux kernel source
char *types[] = {
"status",
"indicator",
NULL,
};
int dreadint(int fd, int *value) {
int ret;
char buf[128];
char *end;
*value = 0;
ret = lseek(fd, 0, SEEK_SET);
if (ret == -1) {
perror("dreadint: lseek");
return -1;
}
ret = read(fd, buf, sizeof(buf) - 1);
if (ret == -1) {
perror("dreadint: read");
return -1;
}
buf[ret] = 0;
ret = strtol(buf, &end, 10);
if (end == buf) {
return -1;
}
*value = ret;
return 0;
}
int parse_color_ids(char *input, int length, enum color colors[]) {
int color_index = 0;
int start = 0;
int i = 0;
memset(colors, COLOR_MAX, sizeof(enum color)*3);
while (i < length) {
// skip whitespace
while (i < length && isspace(input[i])) { i++; }
start = i;
// find the end of the word (next whitespace)
while (i < length && !isspace(input[i])) { i++; }
if (i == start) break;
// now start points to the first char in the word and i is the last
if (strncmp(&input[start], "red", i-start) == 0) {
colors[color_index] = COLOR_RED;
} else if (strncmp(&input[start], "green", i-start) == 0) {
colors[color_index] = COLOR_GREEN;
} else if (strncmp(&input[start], "blue", i-start) == 0) {
colors[color_index] = COLOR_BLUE;
} else {
info("Unknown color: \"%.*s\"\n", i-start, &input[start]);
return false;
}
color_index++;
}
// We expect to find a controls for green, red, and blue channels. To
// check this, we convert the colors we found to a bitflag and compare
// them to what we expected to have. The color enum starts at zero and
// increments by 1, so we can bitshift by that number to decide what bit
// to use.
return (BIT(colors[0]) | BIT(colors[1]) | BIT(colors[2]))
== (BIT(COLOR_RED) | BIT(COLOR_BLUE) | BIT(COLOR_GREEN));
}
bool open_multicolor_led(char *type, struct multicolor_handle *dst) {
int ret, fd = 0;
char buf[128];
memset(dst, 0, sizeof(*dst));
snprintf(buf, sizeof(buf), "%s/rgb:%s/multi_index", led_dir, type);
fd = open(buf, O_RDONLY);
if (fd == -1) {
info("failed to open %s\n", buf);
goto error;
}
int size = read(fd, buf, sizeof(buf));
buf[size] = 0;
if (size <= 0) {
perror("while reading multi_index");
exit(1);
}
close(fd);
if (!parse_color_ids(buf, size, dst->color_ids)) {
info("failed to parse multi_index\n");
goto error;
}
snprintf(buf, sizeof(buf), "%s/rgb:%s/max_brightness", led_dir, type);
fd = open(buf, O_RDONLY);
if (fd <= 0)
goto error;
ret = dreadint(fd, &dst->max_brightness);
if (ret == -1) {
info("dreadint: read: %d\n", errno);
goto error;
}
close(fd);
snprintf(buf, sizeof(buf), "%s/rgb:%s/brightness", led_dir, type);
dst->brightness = fopen(buf, "r+");
if (dst->brightness == NULL)
goto error;
snprintf(buf, sizeof(buf), "%s/rgb:%s/multi_intensity", led_dir, type);
dst->multi_intensity = fopen(buf, "r+");
if (dst->multi_intensity == NULL)
goto error;
return true;
error:
if (fd > 0) close(fd);
if (dst->brightness) fclose(dst->brightness);
if (dst->multi_intensity) fclose(dst->multi_intensity);
return false;
}
int open_monocolor_led(char *color, char *type, bool flip, struct led_handle *led) {
char buf[128];
int fd, ret;
if (flip) {
char *tmp = type;
type = color;
color = tmp;
}
snprintf(buf, sizeof(buf), "%s/%s:%s/brightness", led_dir, color, type);
info("attempting to open %s\n", buf);
led->brightness = open(buf, O_RDWR);
if (led->brightness < 0)
return led->brightness;
snprintf(buf, sizeof(buf), "%s/%s:%s/max_brightness", led_dir, color, type);
fd = open(buf, O_RDONLY);
if (fd <= 0)
return fd;
ret = dreadint(fd, &led->max_brightness);
if (ret == -1) {
info("dreadint: read: %d\n", errno);
}
close(fd);
return ret;
}
bool open_led_group(
struct status_handle *led,
char *type, char *red, char *green, char *blue, bool flip
) {
struct led_handle *ret = led->group;
memset(ret, 0, sizeof(struct led_handle) * 3);
if (-1 == open_monocolor_led(red, type, flip, &ret[COLOR_RED]))
goto error;
if (-1 == open_monocolor_led(green, type, flip, &ret[COLOR_GREEN]))
goto error;
if (-1 == open_monocolor_led(blue, type, flip, &ret[COLOR_BLUE]))
goto error;
return true;
error:
close_single_led(&ret[COLOR_RED]);
close_single_led(&ret[COLOR_GREEN]);
close_single_led(&ret[COLOR_BLUE]);
return false;
}
bool open_status_leds(struct status_handle *led) {
// 1) rgb:status
// 2) rgb:indicator
led->type = LED_MULTICOLOR;
for (int i = 0; types[i] != NULL; i++) {
if (open_multicolor_led(types[i], &led->multicolor))
return true;
}
// We check all the multicolor leds, then all the monocolor leds. It's
// relatively safe to assume that monocolor leds with the same type, are
// in fact the same device, but not guaranteed. Also when
// leds-group-multicolor is in use, one device will have both monocolor
// and multicolor files, but the monocolor ones will be read only.
led->type = LED_GROUP;
// NOTE: these might not be a single led, there's a good chance we'll
// guess right, but we prefer multicolor leds because they don't have
// this issue.
// 3) {red,green,blue}:status
// 4) {red,green,blue}:indicator
for (int i = 0; types[i] != NULL; i++) {
if (open_led_group(led, types[i], "red", "green", "blue", false))
return true;
}
// 5) status-led:{red,green,blue} (Motorola Droid 4)
if (open_led_group(led, "status-led", "red", "green", "blue", true))
return true;
// 6) lp5523:{r,g,b} (Nokia N900)
if (open_led_group(led, "lp5523", "r", "g", "b", true))
return true;
return false;
}
int led_max_brightness(struct status_handle *led, enum color led_color) {
if (led->type == LED_MULTICOLOR) {
return led->multicolor.max_brightness;
} else {
return led->group[led_color].max_brightness;
}
}
int led_pct_to_abs(struct status_handle *led, enum color led_color, double brightness_pct) {
return ceil(brightness_pct * (led_max_brightness(led, led_color) / 100.0));
}
double led_abs_to_pct(struct status_handle *led, enum color led_color, int brightness_pct) {
return brightness_pct * (100.0 / led_max_brightness(led, led_color));
}
led_state led_state_read(struct status_handle *led) {
led_state state = {{ 0, 0, 0 }};
if (led->type == LED_MULTICOLOR) {
int colors[3];
rewind(led->multicolor.multi_intensity);
int ret;
ret = fscanf(led->multicolor.multi_intensity, "%d %d %d", &colors[0], &colors[1], &colors[2]);
if (ret != 3) {
error("Failed to parse multi_intensity file");
return state;
}
for (int i = 0; i < 3; i++) {
state.colors[led->multicolor.color_ids[i]] =
led_abs_to_pct(led, led->multicolor.color_ids[i], colors[i]);
}
// This isn't necessary, but it makes the output more consistent
// for integration tests.
rewind(led->multicolor.multi_intensity);
rewind(led->multicolor.brightness);
return state;
} else if (led->type == LED_GROUP) {
for (int color_id = 0; color_id < COLOR_MAX; color_id++) {
int brightness;
dreadint(led->group[color_id].brightness , &brightness);
state.colors[color_id] = led_abs_to_pct(led, color_id, brightness);
}
return state;
} else {
error("unknown led type. This is a bug.");
exit(1);
}
}
void led_state_write(struct status_handle *led, led_state state, int color_mask) {
if (led->type == LED_MULTICOLOR) {
FILE *intensity = led->multicolor.multi_intensity;
enum color *color_ids = led->multicolor.color_ids;
int all_color_mask = (1<<COLOR_MAX) - 1;
if (color_mask != all_color_mask) {
info("state missing colors, reading them\n");
led_state base_state = led_state_read(led);
for (int i = 0; i < COLOR_MAX; i++) {
if ((color_mask & BIT(i)) == 0)
state.colors[i] = base_state.colors[i];
}
}
info("setting colors: red: %.0f%%, green: %.0f%%, blue: %.0f%% (mask: 0x%x)\n",
state.red, state.green, state.blue, color_mask);
fprintf(intensity, "%d %d %d\n",
// The max brightness for all multicolor leds is the
// same, so we can hard code it
led_pct_to_abs(led, COLOR_MAX, state.colors[color_ids[0]]),
led_pct_to_abs(led, COLOR_MAX, state.colors[color_ids[1]]),
led_pct_to_abs(led, COLOR_MAX, state.colors[color_ids[2]])
);
fprintf(led->multicolor.brightness, "%d", led->multicolor.max_brightness);
fflush(intensity);
fflush(led->multicolor.brightness);
} else if (led->type == LED_GROUP) {
info("setting colors: red: %.0f%%, green: %.0f%%, blue: %.0f%% (mask: 0x%x)\n",
state.red, state.green, state.blue, color_mask);
for (int color_id = 0; color_id < COLOR_MAX; color_id++) {
if (BIT(color_id) & color_mask) {
dprintf(
led->group[color_id].brightness, "%d\n",
led_pct_to_abs(led, color_id, state.colors[color_id])
);
}
}
} else {
error("unknown led type. This is a bug.");
exit(1);
}
}
void blink_pattern(char *colors[], int argc, struct status_handle *led) {
led_state new_state = {{ 0, 0, 0 }};
led_state null_state = {{ 0, 0, 0 }};
led_state old_state = led_state_read(led);
int color_mask = BIT(COLOR_RED) | BIT(COLOR_BLUE) | BIT(COLOR_GREEN);
for (int i=0; i<argc; i++) {
if (strcmp("red", colors[i]) == 0) {
new_state.red = 100;
} else if (strcmp("green", colors[i]) == 0) {
new_state.green = 100;
} else if (strcmp("blue", colors[i]) == 0) {
new_state.blue = 100;
} else {
error("expected color to be one of red, green, or blue. Found %s.", colors[i]);
exit(1);
}
}
led_state_write(led, null_state, color_mask);
nanosleep(&delay_length, NULL);
led_state_write(led, new_state, color_mask);
nanosleep(&delay_length, NULL);
led_state_write(led, null_state, color_mask);
nanosleep(&delay_length, NULL);
led_state_write(led, old_state, color_mask);
}
void set_usage(char *name) {
printf("usage: %s: [-q] [-v] set <color> <value> [color value]...\n", name);
}
int set_main(struct status_handle *led, int argi, int argc, char *argv[]) {
int args = argc - (argi);
int color_mask = 0;
led_state state;
if (args % 2 != 0 || args < 2) {
set_usage(argv[0]);
return 1;
}
for (int i = argi; (i + 1) < argc; i += 2) {
char *color_str = argv[i];
char *value_str = argv[i + 1];
char *end = NULL;
enum color color_id;
errno = 0;
long value = strtol(value_str, &end, 10);
if (end == NULL || *end != 0 || errno) {
error("Unable to convert \"%s\" to a number", value_str);
exit(1);
}
if (strcmp(color_str, "red") == 0) {
color_id = COLOR_RED;
} else if (strcmp(color_str, "green") == 0) {
color_id = COLOR_GREEN;
} else if (strcmp(color_str, "blue") == 0) {
color_id = COLOR_BLUE;
} else {
error("Unknown color \"%s\", expected one of \"red\", \"green\", or \"blue\"", color_str);
}
info("setting color %s(%d) to %ld\n", color_str, color_id, value);
state.colors[color_id] = value;
color_mask |= BIT(color_id);
}
led_state_write(led, state, color_mask);
return 0;
}
int cmd_main(int argc, char *argv[]) {
int argi = 1;
while (argi < argc) {
char *arg = argv[argi];
if (strcmp(arg, "-q") == 0) {
quiet = true;
} else if (strcmp(arg, "-v") == 0) {
verbose = true;
info("enabling verbose mode\n");
} else if (strcmp(arg, "--debug-led-dir") == 0) {
argi++;
if (argi >= argc) {
error("--debug-led-dir requires a path paraemter");
exit(1);
}
led_dir = argv[argi];
} else {
break;
}
argi++;
}
struct status_handle led;
if (!open_status_leds(&led)) {
error("Unable to find suitable status led");
exit(1);
}
info("found a suitable status led\n");
for (int i = argi; i < argc; i++) {
if (strcmp("set", argv[i]) == 0) {
return set_main(&led, i + 1, argc, argv);
} else if (strcmp("blink", argv[i]) == 0) {
blink_pattern(&argv[i+1], argc-i-1, &led);
break;
} else if (strcmp("check", argv[i]) == 0) {
// status leds have already been successfully acquired
return 0;
} else {
fprintf(stderr, "Error: expected command to be one of set, or blink. Found %s\n.", argv[i]);
}
}
return 0;
}
bool parse_color_ids_str(char *input, enum color words[]) {
return parse_color_ids(input, strlen(input), words);
}
#define assert_colors(zero, one, two) \
assert(words[0] == zero && words[1] == one && words[2] == two)
int test_main() {
info("starting test suite\n");
enum color words[3];
bool ret;
ret = parse_color_ids_str("red green blue", words);
assert(ret);
assert_colors(COLOR_RED, COLOR_GREEN, COLOR_BLUE);
// it should handle newlines
ret = parse_color_ids_str("blue green red\n", words);
assert(ret);
assert_colors(COLOR_BLUE, COLOR_GREEN, COLOR_RED);
ret = parse_color_ids_str("green blue red", words);
assert(ret);
assert_colors(COLOR_GREEN, COLOR_BLUE, COLOR_RED);
ret = parse_color_ids_str("green blue brown red", words);
assert(!ret);
ret = parse_color_ids_str("blue red brown", words);
assert(!ret);
ret = parse_color_ids_str("blue green", words);
assert(!ret);
return 0;
}
int main(int argc, char *argv[]) {
#ifdef TEST
return test_main();
#else
return cmd_main(argc, argv);
#endif
}

View File

@@ -11,7 +11,7 @@
menu() {
SUBREDDIT="$(
printf %b "Close Menu\n$(echo "$SXMO_SUBREDDITS" | tr " " '\n')" |
sxmo_dmenu.sh -p "Subreddit:"
sxmo_dmenu_with_kb.sh -p "Subreddit:"
)" || exit 0
[ "Close Menu" = "$SUBREDDIT" ] && exit 0

View File

@@ -5,6 +5,7 @@
# scrot refuses to work with double quotes
# shellcheck disable=SC2016
set -e
exit_msg() {
printf "%s\n" "$1" > /dev/stderr
@@ -21,18 +22,7 @@ sway_screenshot() {
check_command slurp || exit_msg "slurp command must be available to make a selection."
area="$(slurp -o)"
if [ -z "$area" ]; then
area="$(swaymsg -t get_outputs | jq -r '.[] |select (.focused) | .rect | "\(.x),\(.y) \(.width)x\(.height)"')"
fi
wxh=$(echo "$area" | cut -d " " -f 2)
w=$(echo "$wxh" | cut -d "x" -f 1)
h=$(echo "$wxh" | cut -d "x" -f 2)
if [ -n "$wxh" ] && [ "$w" -gt 9 ] && [ "$h" -gt 9 ]; then
#we have a selection (bigger than 9x9)
grim -g "$area" "$1" || exit_msg "Screenshot failed"
else
exit_msg "Invalid screenshot selection (too small)"
fi
grim -g "$area" "$1"
}
xorg_screenshot() {
@@ -77,4 +67,4 @@ screenshot "$FILENAME"
yank "$FILENAME"
printf %s "$FILENAME"
notify-send --urgency=low "Screenshot taken" "$FILENAME"
notify-send --urgency=low "Screenshot taken"

View File

@@ -0,0 +1,5 @@
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# title="$icon_cam Screenshot (selection)"
sxmo_screenshot.sh selection

View File

@@ -6,44 +6,20 @@
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
_finish_timerrun() {
_releasealarm
exit
}
_setupalarm() {
sxmo_sleep -c boottime_alarm "$1" &
alarmpid=$!
}
_releasealarm() {
if [ -n "$alarmpid" ]; then
kill "$alarmpid" 2> /dev/null
unset alarmpid
fi
}
timerrun() {
trap '_finish_timerrun' INT TERM EXIT
TIME="$(
echo "$@" |
sed 's/\([^0-9]\)\([0-9]\)/\1+\2/g; s/h/*60m/g; s/m/*60s/g; s/s//g' |
bc
)"
_setupalarm "$TIME"
DATE1="$(($(date +%s) + TIME))";
while [ "$DATE1" -gt "$(date +%s)" ]; do
while [ "$DATE1" -ge "$(date +%s)" ]; do
printf "%s\r" "$(date -u --date @$((DATE1 - $(date +%s))) +%H:%M:%S)";
sxmo_aligned_sleep 1 &
wait $!
sxmo_aligned_sleep 1
done
echo "Done with $*"
_releasealarm
while : ;
do notify-send "Done with $*";
sxmo_vibrate 1000 "${SXMO_VIBRATE_STRENGTH:-1}"
@@ -51,6 +27,10 @@ timerrun() {
done
}
cleanwakelock() {
sxmo_wakelock.sh unlock sxmo_"$(basename "$0")"
}
stopwatchrun() {
start="$(date +%s)"
while : ; do
@@ -61,7 +41,7 @@ stopwatchrun() {
}
menu() {
TIMEINPUT="$(sxmo_dmenu.sh -p Timer <<EOF
TIMEINPUT="$(sxmo_dmenu_with_kb.sh -p Timer <<EOF
Stopwatch
1h
10m
@@ -83,9 +63,13 @@ EOF
exit 0
;;
"Stopwatch")
sxmo_wakelock.sh lock sxmo_"$(basename "$0")" infinite
trap 'cleanwakelock' INT TERM EXIT
sxmo_terminal.sh "$0" stopwatchrun
;;
*)
sxmo_wakelock.sh lock sxmo_"$(basename "$0")" infinite
trap 'cleanwakelock' INT TERM EXIT
sxmo_terminal.sh "$0" timerrun "$TIMEINPUT"
;;
esac

View File

@@ -138,7 +138,7 @@ weathermenu() {
)" |
grep -vE '^#' |
sed "s/\t/: /g" |
sxmo_dmenu.sh -i -p "Locations"
sxmo_dmenu_with_kb.sh -i -c -l 10 -p "Locations"
)" || exit 0
if [ "$CHOICE" = "Close Menu" ]; then
exit 0

View File

@@ -6,7 +6,7 @@
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
SEARCHQUERY="$(echo "Close Menu" | sxmo_dmenu.sh -p "Search:")" || exit 0
SEARCHQUERY="$(echo "Close Menu" | sxmo_dmenu_with_kb.sh -p "Search:")" || exit 0
case "$SEARCHQUERY" in
"Close Menu") exit 0 ;;

View File

@@ -34,7 +34,7 @@ searchmenu() {
xargs -0 echo |
sed '/^[[:space:]]*$/d' |
awk '{$1=$1};1' |
sxmo_dmenu.sh -p "Yt Search"
sxmo_dmenu_with_kb.sh -p "Yt Search"
)" || exit 0
if [ "Close Menu" = "$ENTRY" ]; then

View File

@@ -81,7 +81,7 @@ getprogchoices() {
NNOTIFICATIONS="$(find "$SXMO_NOTIFDIR" -type f | wc -l)"
if [ "$NNOTIFICATIONS" -gt 0 ]; then
CHOICES="
$icon_bel Notifications ($NNOTIFICATIONS) ^ 0 ^ sxmo_notifs.sh menu
$icon_bel Notifications ($NNOTIFICATIONS) ^ 0 ^ sxmo_notificationsmenu.sh
$CHOICES
"
fi

View File

@@ -16,10 +16,10 @@ notifyvol() {
if [ "muted" = "$vol" ]; then
vol=0
fi
if [ -z "$SXMO_WOB_DISABLE" ]; then
printf "%s\n" "$vol" > "$XDG_RUNTIME_DIR"/sxmo.obsock
if [ "$SXMO_WM" = "sway" ] && [ -z "$SXMO_WOB_DISABLE" ]; then
printf "%s\n" "$vol" > "$XDG_RUNTIME_DIR"/sxmo.wobsock
else
notify-send -r 999 "$icon_audio Volume $vol"
dunstify -r 999 "$icon_audio Volume $vol"
fi
}
@@ -195,22 +195,6 @@ _ringmodesubmenu() {
else
printf " %s Vibrate ^ touch \"$XDG_CONFIG_HOME\"/sxmo/.novibrate\n" "$icon_ton"
fi
if [ -f "$XDG_CONFIG_HOME"/sxmo/.busy ]; then
end="$(cat "$XDG_CONFIG_HOME"/sxmo/.busy)"
if [ -n "$end" ] && [ "$(date +%s)" -gt "$end" ]; then
rm "$XDG_CONFIG_HOME"/sxmo/.busy
fi
fi
if [ -f "$XDG_CONFIG_HOME"/sxmo/.busy ]; then
printf " %s Busy ^ rm -f \"$XDG_CONFIG_HOME\"/sxmo/.busy\n" "$icon_ton"
else
printf " %s Busy ^ touch \"$XDG_CONFIG_HOME\"/sxmo/.busy\n" "$icon_tof"
printf " %s Busy for 15 min ^ date '+%%s+15*60' | bc > \"$XDG_CONFIG_HOME\"/sxmo/.busy\n" "$icon_tmr"
printf " %s Busy for 30 min ^ date '+%%s+30*60' | bc > \"$XDG_CONFIG_HOME\"/sxmo/.busy\n" "$icon_tmr"
printf " %s Busy for 1 hour ^ date '+%%s+60*60' | bc > \"$XDG_CONFIG_HOME\"/sxmo/.busy\n" "$icon_tmr"
printf " %s Busy for 2 hour ^ date '+%%s+2*60*60' | bc > \"$XDG_CONFIG_HOME\"/sxmo/.busy\n" "$icon_tmr"
printf " %s Busy for 3 hour ^ date '+%%s+3*60*60' | bc > \"$XDG_CONFIG_HOME\"/sxmo/.busy\n" "$icon_tmr"
fi
}
menuchoices() {

View File

@@ -5,40 +5,25 @@
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
cleanly_quit() {
kill $BGPROC
}
ROTATION_GRAVITY="${SXMO_ROTATION_GRAVITY:-"16374"}"
ROTATION_THRESHOLD="${SXMO_ROTATION_THRESHOLD:-"400"}"
POLL_TIME="${SXMO_ROTATION_POLL_TIME:-1}"
RIGHT_SIDE_UP="$(echo "$ROTATION_GRAVITY - $ROTATION_THRESHOLD" | bc)"
UPSIDE_DOWN="$(echo "-$ROTATION_GRAVITY + $ROTATION_THRESHOLD" | bc)"
FILE_Y="$(find /sys/bus/iio/devices/iio:device*/ -iname in_accel_y_raw)"
FILE_X="$(find /sys/bus/iio/devices/iio:device*/ -iname in_accel_x_raw)"
# check if iio-sensor-proxy found a proximity sensor
dbus-send --system --dest=net.hadess.SensorProxy --print-reply=literal \
/net/hadess/SensorProxy org.freedesktop.DBus.Properties.Get \
string:net.hadess.SensorProxy string:HasAccelerometer | grep -q 'true' || exit
trap 'cleanly_quit' INT TERM EXIT
monitor-sensor --accel | while read -r line; do
# first line checks if iio-sensor-proxy is running
echo "$line" | grep -qi 'waiting' && continue
# second line confirms iio-sensor-proxy is running
echo "$line" | grep -qi 'appeared' && continue
# read orientation
orientation=$(echo "$line" | cut -d ':' -f 2)
case "$orientation" in
# on the very first sensor claim, the orientation might be
# reported as "undefined." assume "normal" in that case
*"undefined"*|*"normal"*)
while true; do
y_raw="$(cat "$FILE_Y")"
x_raw="$(cat "$FILE_X")"
if [ "$x_raw" -ge "$RIGHT_SIDE_UP" ] && sxmo_rotate.sh isrotated ; then
sxmo_rotate.sh rotnormal
;;
*"bottom-up"*)
elif [ "$x_raw" -le "$UPSIDE_DOWN" ] && [ "$(sxmo_rotate.sh isrotated)" != "invert" ]; then
sxmo_rotate.sh rotinvert
;;
*"left-up"*)
sxmo_rotate.sh rotleft
;;
*"right-up"*)
elif [ "$y_raw" -le "$UPSIDE_DOWN" ] && [ "$(sxmo_rotate.sh isrotated)" != "right" ]; then
sxmo_rotate.sh rotright
;;
esac
done &
BGPROC=$?
wait
elif [ "$y_raw" -ge "$RIGHT_SIDE_UP" ] && [ "$(sxmo_rotate.sh isrotated)" != "left" ]; then
sxmo_rotate.sh rotleft
fi
sleep "$POLL_TIME"
done

View File

@@ -1,12 +0,0 @@
#!/bin/sh
bg="$(sxmo_hook_wallpaper.sh)"
case "$SXMO_WM" in
dwm)
exec feh "${1+--bg-$1}" "$bg"
;;
sway)
exec swaybg -i "$bg" ${1+-m "$1"}
;;
esac

View File

@@ -19,7 +19,7 @@ _prompt() {
_device_list() {
bluetoothctl devices | \
cut -d" " -f2 | \
xargs -rn1 bluetoothctl info | \
xargs -n1 bluetoothctl info | \
awk '
function print_cached_device() {
print icon linkedsep paired connected " " name " " mac
@@ -67,16 +67,25 @@ _full_reconnection() {
notify-send 'Make the device discoverable'
bluetoothctl remove '$1'
sxmo_jobs.sh start bluetooth_scan bluetoothctl --timeout 300 scan on
sxmo_jobs.sh start bluetooth_scan bluetoothctl scan on
sleep 5
while : ; do
timeout 7 bluetoothctl connect '$1'
bluetoothctl --timeout 5 pair '$1'
if bluetoothctl info '$1' | grep -q 'Paired: yes'; then
break
fi
done
sleep 1
bluetoothctl trust '$1'
while : ; do
bluetoothctl --timeout 7 connect '$1'
if bluetoothctl info '$1' | grep -q 'Connected: yes'; then
break
fi
sleep 1
done
"
sxmo_jobs.sh stop bluetooth_scan
@@ -103,9 +112,9 @@ toggle_connection() {
MAC="$(printf "%s\n" "$DEVICE" | awk '{print $NF}')"
if printf "%s\n" "$PICK" | grep -q "$icon_a2x"; then
_can_fail timeout 7 sxmo_terminal.sh bluetoothctl disconnect "$MAC"
_can_fail sxmo_terminal.sh bluetoothctl --timeout 7 disconnect "$MAC"
else
_can_fail timeout 7 sxmo_terminal.sh bluetoothctl connect "$MAC"
_can_fail sxmo_terminal.sh bluetoothctl --timeout 7 connect "$MAC"
fi
}
@@ -145,7 +154,7 @@ EOF
;;
"Paired $icon_tof")
INDEX=2
_can_fail timeout 7 sxmo_terminal.sh bluetoothctl "$MAC"
_can_fail sxmo_terminal.sh bluetoothctl --timeout 7 pair "$MAC"
;;
"Trusted $icon_ton")
INDEX=3
@@ -157,11 +166,11 @@ EOF
;;
"Connected $icon_ton")
INDEX=4
_can_fail timeout 7 sxmo_terminal.sh bluetoothctl disconnect "$MAC"
_can_fail sxmo_terminal.sh bluetoothctl --timeout 7 disconnect "$MAC"
;;
"Connected $icon_tof")
INDEX=4
_can_fail timeout 7 sxmo_terminal.sh bluetoothctl "$MAC"
_can_fail sxmo_terminal.sh bluetoothctl --timeout 7 connect "$MAC"
;;
"Blocked $icon_ton")
INDEX=5

View File

@@ -43,9 +43,9 @@ case "$1" in
off
;;
*) #toggle
if rfkill list bluetooth -no ID,SOFT,HARD | grep -vq " blocked"; then
off
else
if rfkill list bluetooth | grep -q "yes"; then
on
else
off
fi
esac

View File

@@ -9,10 +9,10 @@
. sxmo_hook_icons.sh
notify() {
if [ -z "$SXMO_WOB_DISABLE" ]; then
getvalue > "$XDG_RUNTIME_DIR"/sxmo.obsock
if [ "$SXMO_WM" = "sway" ] && [ -z "$SXMO_WOB_DISABLE" ]; then
getvalue > "$XDG_RUNTIME_DIR"/sxmo.wobsock
else
getvalue | xargs notify-send -r 888 "$icon_brightness Brightness"
getvalue | xargs dunstify -r 888 "$icon_brightness Brightness"
fi
}
@@ -28,18 +28,11 @@ down() {
# bugged https://github.com/Hummer12007/brightnessctl/issues/82
# brightnessctl --min-value "${SXMO_MIN_BRIGHTNESS:-5}" set 5%-
value="$(getvalue)"
if [ "$value" -le "${SXMO_MIN_BRIGHTNESS:-5}" ]; then
return
fi
if [ "$((value-5))" -ge "${SXMO_MIN_BRIGHTNESS:-5}" ]; then
if [ "$(getvalue)" -gt "${SXMO_MIN_BRIGHTNESS:-5}" ]; then
brightnessctl -q set 5%-
return
fi
else
brightnessctl -q set "${SXMO_MIN_BRIGHTNESS:-5}"%
fi
}
getvalue() {

View File

@@ -6,27 +6,11 @@
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
if [ -z "$SXMO_MENU" ]; then
case "$SXMO_WM" in
sway)
SXMO_MENU=bemenu
;;
dwm)
SXMO_MENU=dmenu
;;
esac
fi
case "$SXMO_MENU" in
dmenu)
exec dmenu_run "$@"
;;
bemenu)
sway)
exec bemenu-run "$@"
;;
wofi)
exec wofi -O alphabetical -i --show run "$@"
;;
esac

View File

@@ -15,6 +15,7 @@ command -v shopt > /dev/null && shopt -s expand_aliases
alias dmenu="sxmo_dmenu.sh"
alias bemenu="sxmo_dmenu.sh"
command -v gojq > /dev/null && alias jq="gojq" # better performances
if ! command -v sxmobar > /dev/null; then
sxmobar() {
@@ -64,7 +65,7 @@ xdg_data_path() {
break
fi
if [ $instance -gt 0 ]; then
printf '%b' "${sep}"
printf '%s' "${sep}"
fi
printf '%s' "${dir}/${filepath}"
instance=$((instance+1))

View File

@@ -11,7 +11,7 @@ set -e
# shellcheck disable=SC2120
newcontact() {
name="$(printf "" | sxmo_dmenu.sh -p "$icon_usr Name")"
name="$(printf "" | sxmo_dmenu_with_kb.sh -p "$icon_usr Name")"
number="$1"
if [ -n "$number" ]; then
@@ -19,7 +19,7 @@ newcontact() {
fi
while [ -z "$number" ]; do
number="$(sxmo_contacts.sh --unknown | sxmo_dmenu.sh -p "$icon_phl Number")"
number="$(sxmo_contacts.sh --unknown | sxmo_dmenu_with_kb.sh -p "$icon_phl Number")"
number="$(sxmo_validnumber.sh "$number")" || continue
done
@@ -35,7 +35,7 @@ editcontactname() {
ENTRIES="$(printf %b "Old name: $oldname")"
PICKED="$(
printf %b "$ENTRIES" |
sxmo_dmenu.sh -p "$icon_edt Edit Contact"
sxmo_dmenu_with_kb.sh -p "$icon_edt Edit Contact"
)"
if ! printf %s "$PICKED" | grep -q "^Old name: "; then
@@ -56,7 +56,7 @@ editcontactnumber() {
while [ -z "$PICKED" ]; do
PICKED="$(
printf %b "$ENTRIES" |
sxmo_dmenu.sh -p "$icon_edt Edit Contact"
sxmo_dmenu_with_kb.sh -p "$icon_edt Edit Contact"
)"
if printf %s "$PICKED" | grep -q "(Old number)$"; then
editcontact "$1"
@@ -166,7 +166,7 @@ main() {
PICKED="$(
printf %b "$ENTRIES" |
sxmo_dmenu.sh -i -p "$icon_lst Contacts"
sxmo_dmenu_with_kb.sh -i -p "$icon_lst Contacts"
)"
case "$PICKED" in

View File

@@ -5,13 +5,6 @@
# We still use dmenu in dwm|worgs cause pointer/touch events
# are not implemented yet in the X11 library of bemenu
# Note: Only pass parameters to this script that are unambiguous across all
# supported implementations! (dmenu, wofi, dmenu), which are only:
# -p PROMPT
# -i (case insensitive)
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
@@ -20,46 +13,26 @@
unalias bemenu
unalias dmenu
if [ -z "$SXMO_MENU" ]; then
case "$SXMO_WM" in
sway)
SXMO_MENU=bemenu
;;
dwm)
SXMO_MENU=dmenu
;;
esac
fi
case "$1" in
isopen)
case "$SXMO_MENU" in
bemenu)
case "$SXMO_WM" in
sway)
exec pgrep bemenu >/dev/null
;;
wofi)
exec pgrep wofi >/dev/null
;;
dmenu)
dwm)
exec pgrep dmenu >/dev/null
;;
esac
;;
close)
case "$SXMO_MENU" in
bemenu)
case "$SXMO_WM" in
sway)
if ! pgrep bemenu >/dev/null; then
exit
fi
exec pkill bemenu >/dev/null
;;
wofi)
if ! pgrep wofi >/dev/null; then
exit
fi
exec pkill wofi >/dev/null
;;
dmenu)
dwm)
if ! pgrep dmenu >/dev/null; then
exit
fi
@@ -70,45 +43,40 @@ case "$1" in
esac
if [ -n "$WAYLAND_DISPLAY" ]; then
if sxmo_state.sh get | grep -q unlock; then
if grep -q unlock "$SXMO_STATE"; then
swaymsg mode menu -q # disable default button inputs
cleanmode() {
swaymsg mode default -q
}
trap 'cleanmode' TERM INT
fi
fi
if [ -n "$WAYLAND_DISPLAY" ] || [ -n "$DISPLAY" ]; then
case "$SXMO_MENU" in
bemenu)
bemenu -l "$(sxmo_rotate.sh isrotated > /dev/null && \
printf %s "${SXMO_BEMENU_LANDSCAPE_LINES:-8}" || \
printf %s "${SXMO_BEMENU_PORTRAIT_LINES:-16}")" "$@"
returned=$?
[ -n "$WAYLAND_DISPLAY" ] && cleanmode
exit "$returned"
;;
wofi)
#let wofi handle the number of lines dynamically
# (wofi is a bit confused after rotating to horizontal mode though)
# shellcheck disable=SC2046
# (not quoted because we want to split args here)
wofi $(sxmo_rotate.sh isrotated > /dev/null && echo -W "${SXMO_WOFI_LANDSCAPE_WIDTH:-640}" -H "${SXMO_WOFI_LANDSCAPE_HEIGHT:-200}" -l top) "$@"
returned=$?
cleanmode
exit "$returned"
;;
dmenu)
fi
if [ -n "$DISPLAY" ]; then
# TODO: kill dmenu?
if sxmo_keyboard.sh isopen; then
# shellcheck disable=SC2086
exec dmenu $SXMO_DMENU_OPTS -l "$(sxmo_rotate.sh isrotated > /dev/null && \
printf %s "${SXMO_DMENU_LANDSCAPE_LINES:-5}" || \
printf %s "${SXMO_DMENU_PORTRAIT_LINES:-12}")" "$@"
;;
esac
printf %s "${SXMO_DMENU_WITH_KB_LANDSCAPE_LINES:-5}" || \
printf %s "${SXMO_DMENU_WITH_KB_PORTRAIT_LINES:-12}")" "$@"
else
#fallback to tty menu (e.g. over ssh)
# shellcheck disable=SC2086
exec dmenu $SXMO_DMENU_OPTS -l "$(sxmo_rotate.sh isrotated > /dev/null && \
printf %s "${SXMO_DMENU_LANDSCAPE_LINES:-7}" || \
printf %s "${SXMO_DMENU_PORTRAIT_LINES:-15}")" "$@"
fi
exit
fi
export BEMENU_BACKEND=curses
exec bemenu -w "$@"
fi

View File

@@ -0,0 +1,21 @@
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
if [ -n "$WAYLAND_DISPLAY$DISPLAY" ]; then
if sxmo_keyboard.sh isopen; then
wasopen="1"
fi
sxmo_keyboard.sh open
sleep .1 # give keyboard time to open
fi
OUTPUT="$(cat | sxmo_dmenu.sh "$@")"
exitcode=$?
if [ -z "$wasopen" ]; then
sxmo_keyboard.sh close
fi
printf %s "$OUTPUT"
exit $exitcode

View File

@@ -1,9 +1,9 @@
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2024 Sxmo Contributors
# Copyright 2022 Sxmo Contributors
if [ "$(brightnessctl -d "white:flash" get)" -gt 0 ]; then
brightnessctl -q -d "white:flash" set "0%"
if sxmo_led.sh get white | grep -vq ^100$; then
sxmo_led.sh set white 100
else
brightnessctl -q -d "white:flash" set "100%"
sxmo_led.sh set white 0
fi

View File

@@ -25,12 +25,6 @@ finish() {
exit
}
shared_envvars() {
if ! sxmo_status_led check; then
export SXMO_DISABLE_LEDS="1"
fi
}
init() {
# shellcheck source=/dev/null
. /etc/profile.d/sxmo_init.sh
@@ -38,7 +32,6 @@ init() {
_sxmo_load_environments
_sxmo_prepare_dirs
envvars
shared_envvars
sxmo_migrate.sh sync
defaults

View File

@@ -14,13 +14,10 @@ isopen() {
}
open() {
if [ -n "$SXMO_NO_VIRTUAL_KEYBOARD" ]; then
return
fi
if [ -n "$KEYBOARD" ]; then
#Note: KEYBOARD_ARGS is not quoted by design as it may includes a pipe and further tools
# shellcheck disable=SC2086
isopen || eval "$KEYBOARD" $KEYBOARD_ARGS >> "${XDG_STATE_HOME:-$HOME}"/sxmo.log 2>&1 &
isopen || eval "$KEYBOARD" $KEYBOARD_ARGS &
fi
}

View File

@@ -5,17 +5,79 @@
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
set -e
get_led() {
color="$1"
usage() {
printf "usage: %s get [red|green|blue|white]\n" "$0"
exit 1
}
[ $# -lt 1 ] && usage
# need brightnessctl release after 0.5.1 to have --percentage
value="$(brightnessctl -d "$color:*" get)"
max="$(brightnessctl -d "$color:*" max)"
printf "scale=0; %s / %s * 100\n" "$value" "$max" | bc -l
}
set_led() {
usage (){
printf "usage: %s set [red|green|blue|white] [0-100]\n" "$0"
exit 1
}
[ $# -lt 2 ] && usage
color="$1"
percent="$2"
brightnessctl -q -d "$color:*" set "$percent%"
}
set_leds() {
while [ "$#" -ge 2 ]; do
set_led "$1" "$2" &
shift 2
done
wait
}
finish_blinking() {
sxmo_wakelock.sh unlock sxmo_playing_with_leds
trap - INT TERM EXIT
eval set_leds green '$'old_green blue '$'old_blue red '$'old_red ${white:+white '$'old_white}
exit
}
blink_leds() {
for color in green blue red white; do
percent="$(get_led "$color")"
eval "old_$color=$percent" # store old value
done
sxmo_wakelock.sh lock sxmo_playing_with_leds 2s
trap 'finish_blinking' TERM INT EXIT
sxmo_status_led blink "$@"
while [ -n "$1" ]; do
case "$1" in
green|blue|red|white)
eval "$1=100"
shift
;;
esac
done
# shellcheck disable=SC2154
set_leds green 0 blue 0 red 0 ${white:+white 0}
sleep 0.1 # Make blink noticable
set_leds green "${green:-0}" blue "${blue:-0}" red "${red:-0}" ${white:+white "${white:-0}"}
sleep 0.1 # Make blink noticable
set_leds green 0 blue 0 red 0 ${white:+white 0}
sleep 0.1 # Make blink noticable
}
[ -z "$SXMO_DISABLE_LEDS" ] || exit 1
@@ -25,12 +87,12 @@ exec 3<> "${XDG_RUNTIME_DIR:-$HOME}/sxmo.led.lock"
cmd="$1"
shift
case "$cmd" in
set)
"set"|blink)
flock -x 3
sxmo_status_led set "$@"
"$cmd"_leds "$@"
;;
blink)
flock -x 3
blink_leds "$@"
get)
flock -s 3
get_led "$@"
;;
esac

View File

@@ -15,28 +15,10 @@ if [ -z "$SXMO_DEVICE_NAME" ]; then
fi
smartdiff() {
#argument one is the system default
#argument two is the user version (to be migrated)
if [ "$SXMO_MIGRATE_ORDER" = "user:system" ]; then
printf "Your user file is in \e[31mred (-)\e[0m, the system default in \e[32mgreen (+)\e[0m\n"
if command -v colordiff > /dev/null; then
colordiff "$@"
else
printf "The system default is in \e[31mred (-)\e[0m, your user changes in \e[32mgreen (+)\e[0m\n"
#swap arguments
set -- "$2" "$1"
echo "$@"
fi
if command -v delta > /dev/null; then
# shellcheck disable=SC2086
delta "$@"
elif command -v colordiff > /dev/null; then
# shellcheck disable=SC2086
colordiff -ud "$@"
else
# poor man's ad-hoc colordiff
ESC=$(printf "\e")
# shellcheck disable=SC1087
diff -ud "$@" | sed -E -e "s/^-(.*)$/-$ESC[31m\1$ESC[0m/" -e "s/^\+(.*)$/+$ESC[32m\1$ESC[0m/" -e "s/^@@(.*)$/$ESC[34m@@\1$ESC[0m/"
diff "$@"
fi
}
@@ -50,7 +32,7 @@ resolvedifference() {
(
printf "\e[31mThe file \e[32m%s\e[31m differs\e[0m\n" "$userfile"
smartdiff "$userfile" "$defaultfile"
smartdiff -ud "$defaultfile" "$userfile"
) | more
printf "\e[31mMigration options for \e[32m%s\e[31m:\e[0m\n" "$userfile"
@@ -59,7 +41,6 @@ resolvedifference() {
printf "2 - Open [e]ditor and merge the changes yourself; take care to set the same configversion.\n"
printf "3 - Use your [u]ser version as-is; you verified it's compatible. (Auto-updates configversion only).\n"
printf "4 - [i]gnore, do not resolve and don't change anything, ask again next time. (default)\n"
printf "5 - Change the diff argument [o]rder and ask again\n"
printf "\e[33mHow do you want to resolve this? Choose one of the options above [1234deui]\e[0m "
@@ -83,17 +64,9 @@ resolvedifference() {
#open editor with both files and the diff
export DIFFTOOL="${DIFFTOOL:-vimdiff}"
if [ -n "$DIFFTOOL" ] && command -v "$DIFFTOOL" >/dev/null; then # ex vimdiff
if [ "$SXMO_MIGRATE_ORDER" = "user:system" ]; then
set -- "$DIFFTOOL" "$userfile" "$defaultfile"
else
set -- "$DIFFTOOL" "$defaultfile" "$userfile"
fi
else
if [ "$SXMO_MIGRATE_ORDER" = "user:system" ]; then
diff -u "$userfile" "$defaultfile" > "${XDG_RUNTIME_DIR}/migrate.diff"
else
diff -u "$defaultfile" "$userfile" > "${XDG_RUNTIME_DIR}/migrate.diff"
fi
# shellcheck disable=SC2086
set -- $EDITOR "$userfile" "$defaultfile" "${XDG_RUNTIME_DIR}/migrate.diff"
fi
@@ -119,13 +92,6 @@ resolvedifference() {
sed -i "2i$refline" "$userfile" || abort=1
fi
;;
[5oO]*)
if [ "$SXMO_MIGRATE_ORDER" = "user:system" ]; then
SXMO_MIGRATE_ORDER="system:user"
else
SXMO_MIGRATE_ORDER="user:system"
fi
;;
*)
abort=1
;;
@@ -143,6 +109,9 @@ resolvedifference() {
}
checkconfigversion() {
if [ -n "$SXMO_DISABLE_CONFIGVERSION_CHECK" ]; then
return 0
fi
userfile="$1"
reffile="$2"
if [ ! -e "$userfile" ] || [ ! -e "$reffile" ]; then
@@ -283,7 +252,7 @@ checkhooks() {
fi
elif [ "$MODE" != "sync" ]; then
(
smartdiff "$hook" "/dev/null"
smartdiff -ud "/dev/null" "$hook"
printf "\e[31mThe hook \e[32m%s\e[31m does not exist (anymore), remove it? [y/N] \e[0m\n" "$hook"
) | more
read -r reply < /dev/tty
@@ -307,8 +276,6 @@ sway() {
defaultconfig "$(xdg_data_path sxmo/appcfg/bonsai_tree.json)" "$XDG_CONFIG_HOME/sxmo/bonsai_tree.json" 644
defaultconfig "$(xdg_data_path sxmo/appcfg/wob.ini)" "$XDG_CONFIG_HOME/wob/wob.ini" 644
defaultconfig "$(xdg_data_path sxmo/appcfg/conky.conf)" "$XDG_CONFIG_HOME/sxmo/conky.conf" 644
defaultconfig "$(xdg_data_path sxmo/appcfg/wofi.config)" "$XDG_CONFIG_HOME/wofi/config" 644
defaultconfig "$(xdg_data_path sxmo/appcfg/wofi.css)" "$XDG_CONFIG_HOME/wofi/style.css" 644
}
xorg() {

View File

@@ -24,7 +24,7 @@ menu() {
dmenu -i "$@"
}
notify_success() {
notify_sucess() {
MSG="$1"
shift
if "$@"; then
@@ -55,7 +55,7 @@ toggleconnection() {
CONNLINE="$1"
if echo "$CONNLINE" | grep -q "^$icon_don "; then
CONNNAME="$(echo "$CONNLINE" | cut -d' ' -f3-)"
notify_success "Disabling connection" \
notify_sucess "Disabling connection" \
nmcli c down "$CONNNAME"
else
CONNNAME="$(echo "$CONNLINE" | cut -d' ' -f3-)"
@@ -64,21 +64,11 @@ toggleconnection() {
sxmo_notify_user.sh "Enabling wifi first."
doas sxmo_wifitoggle.sh
fi
notify_success "Enabling connection" \
notify_sucess "Enabling connection" \
nmcli c up "$CONNNAME"
fi
}
togglegsm() {
if nmcli radio wwan | grep -q "enabled"; then
sxmo_notify_user.sh "Disabling GSM"
nmcli radio wwan off
else
sxmo_notify_user.sh "Enabling GSM"
nmcli radio wwan on
fi
}
deletenetworkmenu() {
CHOICE="$(
printf %b "$icon_cls Close Menu\n$(connections)" |
@@ -87,7 +77,7 @@ deletenetworkmenu() {
[ -z "$CHOICE" ] && return
echo "$CHOICE" | grep -q "Close Menu" && return
CONNNAME="$(echo "$CHOICE" | cut -d' ' -f3-)"
notify_success "Deleting connection" \
notify_sucess "Deleting connection" \
nmcli c delete "$CONNNAME"
}
@@ -104,14 +94,14 @@ getifname() {
addnetworkgsmmenu() {
CONNNAME="$(
echo "$icon_cls Close Menu" |
sxmo_dmenu.sh -p "Alias"
sxmo_dmenu_with_kb.sh -p "Alias"
)"
[ -z "$CONNNAME" ] && return
echo "$CONNNAME" | grep -q "Close Menu" && return
APN="$(
echo "$icon_cls Close Menu" |
sxmo_dmenu.sh -p "APN"
sxmo_dmenu_with_kb.sh -p "APN"
)"
[ -z "$APN" ] && return
echo "$APN" | grep -q "Close Menu" && return
@@ -136,27 +126,22 @@ addnetworkgsmmenu() {
;;
esac
notify_success "Adding connection" \
notify_sucess "Adding connection" \
nmcli c add type gsm ifname "$(getifname gsm)" con-name "$CONNNAME" \
apn "$APN" ${PASSWORD:+gsm.password "$PASSWORD"} \
${USERNAME:+gsm.username "$USERNAME"}
}
addnetworkwpamenu() {
SSID="$(cat <<EOF | sxmo_dmenu.sh -p "SSID"
SSID="$(cat <<EOF | sxmo_dmenu_with_kb.sh -p "SSID"
$icon_cls Close Menu
$(nmcli -t -f SSID,SECURITY dev wifi | awk '!seen[$0]++' | sed 's/:/ /')
$(nmcli d wifi list | tail -n +2 | grep -v '^\*' | awk -F' ' '{ print $6 }' | grep -v '\-\-')
EOF
)"
[ -z "$SSID" ] && return
echo "$SSID" | grep -q "Close Menu" && return
SECURITY_TYPE="$(echo "$SSID" | cut -d" " -f 2)"
SSID="$(echo "$SSID" | cut -d" " -f 1)"
# If no security type, or it is '--' (not sure if this happens in terse mode), skip passphrase input
if [ -n "$SECURITY_TYPE" ] && [ "$SECURITY_TYPE" != "--" ]; then
PASSPHRASE="$(cat <<EOF | sxmo_dmenu.sh -p "Passphrase"
PASSPHRASE="$(cat <<EOF | sxmo_dmenu_with_kb.sh -p "Passphrase"
$icon_cls Close Menu
None
EOF
@@ -166,9 +151,8 @@ EOF
unset PASSPHRASE
fi
echo "$PASSPHRASE" | grep -q "Close Menu" && return
fi
notify_success "Adding connection" \
notify_sucess "Adding connection" \
nmcli c add type wifi ifname wlan0 con-name "$SSID" ssid "$SSID" \
${PASSPHRASE:+802-11-wireless-security.key-mgmt wpa-psk 802-11-wireless-security.psk "$PASSPHRASE"}
}
@@ -176,13 +160,13 @@ EOF
addhotspotusbmenu() {
CONNNAME="$(
echo "$icon_cls Close Menu" |
sxmo_dmenu.sh -p "Alias"
sxmo_dmenu_with_kb.sh -p "Alias"
)"
[ -z "$CONNNAME" ] && return
echo "$CONNNAME" | grep -q "Close Menu" && return
# TODO: restart udhcpd after disconnecting on postmarketOS
notify_success "Adding hotspot" \
notify_sucess "Adding hotspot" \
nmcli c add type ethernet ifname usb0 con-name "$CONNNAME" \
ipv4.method shared
}
@@ -190,21 +174,21 @@ addhotspotusbmenu() {
addhotspotwifimenu() {
SSID="$(
echo "$icon_cls Close Menu" |
sxmo_dmenu.sh -p "SSID"
sxmo_dmenu_with_kb.sh -p "SSID"
)"
[ -z "$SSID" ] && return
echo "$SSID" | grep -q "Close Menu" && return
key="$(
echo "$icon_cls Close Menu" |
sxmo_dmenu.sh -p "Passphrase"
sxmo_dmenu_with_kb.sh -p "Passphrase"
)"
[ -z "$key" ] && return
echo "$key" | grep -q "Close Menu" && return
key1="$(
echo "$icon_cls Close Menu" |
sxmo_dmenu.sh -p "Confirm"
sxmo_dmenu_with_kb.sh -p "Confirm"
)"
[ -z "$key1" ] && return
echo "$key1" | grep -q "Close Menu" && return
@@ -226,12 +210,12 @@ addhotspotwifimenu() {
fi
channel="$(
printf "%s Close Menu\n11\n" "$icon_cls" | sxmo_dmenu.sh -p "Channel"
printf "%s Close Menu\n11\n" "$icon_cls" | sxmo_dmenu_with_kb.sh -p "Channel"
)"
[ -z "$channel" ] && return
echo "$channel" | grep -q "Close Menu" && return
notify_success "Adding hotspot wifi" \
notify_sucess "Adding hotspot wifi" \
nmcli device wifi hotspot ifname wlan0 con-name "Hotspot $SSID" \
ssid "$SSID" channel "$channel" band bg password "$key"
}
@@ -263,13 +247,6 @@ $(
fi
)
$icon_cfg Nmtui
$(
if nmcli radio wwan | grep -q "enabled"; then
printf "%s Disable GSM\n" $icon_modem_disabled
else
printf "%s Enable GSM\n" $icon_modem_registered
fi
)
$icon_cfg Ifconfig
$([ -z "$WIFI_ENABLED" ] || printf "%s Scan Wifi Networks\n" "$icon_wif")
EOF
@@ -297,9 +274,6 @@ EOF
*"Nmtui" )
sxmo_terminal.sh nmtui || continue # Killeable
;;
*"Disable GSM"|*"Enable GSM" )
togglegsm
;;
*"Ifconfig" )
sxmo_terminal.sh watch -n 2 ifconfig || continue # Killeable
;;

View File

@@ -1,193 +0,0 @@
#!/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
# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh
. sxmo_hook_icons.sh
_clear_notif_group() {
find "$SXMO_NOTIFDIR" -type f | while read -r file; do
if awk NR==1 "$file" | grep -lxq "$1"; then
rm "$file"
fi
done
}
_handle_new_notif_file(){
file="$1"
if [ "$(wc -l "$file" | cut -d' ' -f1)" -lt 3 ]; then
sxmo_log "Invalid notification file $file found, deleting!"
rm -f "$file"
return
fi
sxmo_hook_notification.sh "$file" &
group="$(awk NR==1 "$file")"
action="$(awk NR==2 "$file")"
msg="$(tail -n+3 "$file" | cut -c1-70)"
case "$(dunstify --action="default,Open" "$msg")" in
"2")
#
# _clear_notif_group "$group"
#
;;
"default")
_clear_notif_group "$group"
setsid -f sh -c "$action" > /dev/null 2>&1
;;
esac
}
_notifications_hook() {
sxmo_hook_notifications.sh "$(find "$SXMO_NOTIFDIR"/ -type f | wc -l)"
}
monitor() {
mkdir -p "$SXMO_NOTIFDIR"
find "$SXMO_NOTIFDIR" -type f | while read -r file; do
_handle_new_notif_file "$file"
done
_notifications_hook
fifo="$(mktemp -u)"
mkfifo "$fifo"
inotifywait -mq -e attrib,move,delete "$SXMO_NOTIFDIR" >> "$fifo" &
inotif_pid=$!
finish() {
kill "$inotif_pid"
rm "$fifo"
exit
}
trap 'finish' TERM INT EXIT
while read -r notif_folder notif_type notif_file; do
if echo "$notif_type" | grep -qE "CREATE|MOVED_TO|ATTRIB"; then
_handle_new_notif_file "$notif_folder$notif_file"
fi
_notifications_hook
done < "$fifo"
wait "$inotif_pid"
}
_menu_lines() {
find "$SXMO_NOTIFDIR" -type f | while read -r file; do
msg="$(tail -n+3 "$file" | tr "\n^" " ")"
hrandmin="$(stat --printf %y "$file" | grep -oE '[0-9]{2}:[0-9]{2}')"
cat <<EOF
$hrandmin $msg^$file
EOF
done
}
menu() {
choices="$(cat <<EOF
$icon_cls Close Menu
$icon_del Clear Notifications
$(_menu_lines)
EOF
)"
picked="$(
printf "%b" "$choices" |
cut -d^ -f1 |
sxmo_dmenu.sh -i -p "Notifs"
)"
case "$picked" in
"$icon_cls Close Menu"|"")
exit
;;
"$icon_del Clear Notifications")
rm "$SXMO_NOTIFDIR"/*
# we must update statusbar here because this function depends
# on number of files in $SXMO_NOTIFDIR
sxmo_hook_statusbar.sh notifications
exit
;;
*)
file="$(
printf "%b" "$choices" |
grep -F "$picked" |
cut -d^ -f2
)"
group="$(awk NR==1 "$file")"
action="$(awk NR==2 "$file")"
_clear_notif_group "$group"
setsid -f sh -c "$action" > /dev/null 2>&1
;;
esac
}
new() {
while : ; do
case "$1" in
-i)
id="$2"
shift 2
;;
-g)
group="$2"
shift 2
;;
*)
break
;;
esac
done
if [ "$#" -lt 2 ]; then
usage
exit 1
fi
if [ -z "$id" ]; then
id="$(tr -dc 'a-zA-Z0-9' < /dev/urandom 2>/dev/null | head -c 10)"
fi
if [ -z "$group" ]; then
group="$(tr -dc 'a-zA-Z0-9' < /dev/urandom 2>/dev/null | head -c 10)"
fi
action="$1"
msg="$2"
touch "$SXMO_NOTIFDIR/$id"
printf "%s\n%s\n%b\n" "$group" "$action" "$msg" > "$SXMO_NOTIFDIR/$id"
sxmo_hook_statusbar.sh notifications
}
usage() {
cat <<EOF
$(basename "$0"): manage sxmo notifications
Subcommands:
monitor
Watch for new notification, dispatch libnotify events, handle actions
menu
Open a menu to dismiss notifications
new [-i id] [-g group] <action> <message...>
Register a new notification
EOF
}
cmd="$1"
shift
case "$cmd" in
monitor) monitor "$@";;
menu) menu "$@";;
new) new "$@";;
*)
usage
exit 1
;;
esac

View File

@@ -336,5 +336,9 @@ fi
if [ $# -gt 0 ]; then
set -- "${1#file://}"
run "$@"
if [ "$attached" = "1" ]; then
xdg-open "$@"
else
xdg-open "$@" &
fi
fi

View File

@@ -9,7 +9,7 @@ menu() {
printf %b "$(
echo "Close Menu";
echo "$INPUT" | grep -Eo '\S+' | tr -d '[:blank:]' | sort | uniq
)" | sxmo_dmenu.sh -p "$PROMPT" -i
)" | sxmo_dmenu_with_kb.sh -p "$PROMPT" -i
)"
}

View File

@@ -24,11 +24,11 @@ resume_all() {
}
if ! command -v playerctl >/dev/null; then
exit
return
fi
if ! playerctl status >/dev/null 2>&1; then
exit
return
fi
case "$1" in

View File

@@ -9,22 +9,44 @@
# This hook enables the proximity lock.
finish() {
kill "$EVENTMONITORPID"
kill "$TAILPID"
rm "$tmp"
# De-activate thresholds
printf 0 > "$prox_path/events/in_proximity_thresh_falling_value"
# The in_proximity_scale affects the maximum threshold value
# (see static const int stk3310_ps_max[4])
printf 6553 > "$prox_path/events/in_proximity_thresh_rising_value"
sxmo_wakelock.sh unlock sxmo_proximity_lock_running
sxmo_state.sh restore "$storeid"
if [ -n "$INITIALSTATE" ]; then
sxmo_state.sh set "$INITIALSTATE"
fi
exit
}
near() {
if [ -z "$INITIALSTATE" ]; then
INITIALSTATE="$(cat "$SXMO_STATE")"
fi
sxmo_debug "near"
sxmo_state.sh set screenoff
}
far() {
if [ -z "$INITIALSTATE" ]; then
INITIALSTATE="$(cat "$SXMO_STATE")"
fi
sxmo_debug "far"
sxmo_state.sh set unlock
}
trap 'finish' TERM INT EXIT
trap 'finish' TERM INT
sxmo_wakelock.sh lock sxmo_proximity_lock_running infinite
@@ -34,17 +56,35 @@ if [ -z "$SXMO_PROX_RAW_BUS" ]; then
else
prox_raw_bus="$SXMO_PROX_RAW_BUS"
fi
prox_path="$(dirname "$prox_raw_bus")"
prox_name="$(cat "$prox_path/name")" # e.g. stk3310
storeid="$(sxmo_state.sh store)"
# set some sane defaults
printf "%d" "${SXMO_PROX_FALLING:-50}" > "$prox_path/events/in_proximity_thresh_falling_value"
printf "%d" "${SXMO_PROX_RISING:-100}" > "$prox_path/events/in_proximity_thresh_rising_value"
while : ; do
value="$(cat "$prox_raw_bus")"
if [ "$value" -gt 100 ] && [ "$last" != "near" ]; then
tmp="$(mktemp)"
# TODO: stdbuf not needed with linux-tools-iio >=5.17
stdbuf -o L iio_event_monitor "$prox_name" >> "$tmp" &
EVENTMONITORPID=$!
tail -f "$tmp" | while read -r line; do
if echo "$line" | grep -q rising; then
near
last=near
elif [ "$value" -lt 100 ] && [ "$last" != "far" ]; then
elif echo "$line" | grep -q falling; then
far
last=far
fi
sleep 0.5
done
done &
TAILPID=$!
initial_distance="$(cat "$prox_raw_bus")"
if [ "$initial_distance" -gt "${SXMO_PROX_FALLING:-50}" ]; then
near
elif [ "$initial_distance" -lt "${SXMO_PROX_RISING:-100}" ]; then
far
fi
wait
finish

View File

@@ -7,7 +7,16 @@
. sxmo_common.sh
exec sxmo_wakelock.sh run sh -c '
# We can have multiple cronjobs at the same time
sxmo_wakelock.sh lock sxmo_executing_cronjob_$$ infinite
sxmo_wakelock.sh unlock sxmo_waiting_cronjob
exec "$@"
' "" "$@"
finish() {
sxmo_wakelock.sh unlock sxmo_executing_cronjob_$$
exit 0
}
trap 'finish' TERM INT EXIT
sxmo_log "Running $*"
"$@"

View File

@@ -2,40 +2,13 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
usage() {
cat <<-EOF >&2
Usage: $(basename "$0") [-w] [-c <clock-name>] <timeout> [--] <cmd...>
EOF
exit 1
}
while [ -n "$*" ]; do
case "$1" in
"--")
shift
break;
;;
"-w")
if [ "$1" = "-" ]; then
waitfirst=1
shift
;;
"-c")
clockname="$2"
shift 2
;;
*)
if [ -n "$timeout" ]; then
break;
fi
timeout="$1"
shift
;;
esac
done
if [ -z "$timeout" ] || [ -z "$*" ]; then
usage
fi
finish() {
[ -n "$CMDPID" ] && kill "$CMDPID"
@@ -46,7 +19,7 @@ finish() {
trap 'finish' TERM INT
if [ -n "$waitfirst" ]; then
sxmo_sleep ${clockname:+-c $clockname} "$timeout" &
sleep "$timeout" &
SLEEPPID="$!"
wait "$SLEEPPID"
unset SLEEPPID
@@ -58,7 +31,7 @@ while : ; do
wait "$CMDPID"
unset CMDPID
sxmo_sleep ${clockname:+-c $clockname} "$timeout" &
sleep "$timeout" &
SLEEPPID="$!"
wait "$SLEEPPID"
unset SLEEPPID

View File

@@ -4,13 +4,7 @@
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
SXMO_STATE="${SXMO_STATE:-$XDG_RUNTIME_DIR/sxmo.state}"
if command -v peanutbutter > /dev/null; then
#no separate lock stage needed when peanutbutter is used
SXMO_STATES="${SXMO_STATES:-unlock screenoff}"
else
SXMO_STATES="${SXMO_STATES:-unlock lock screenoff}"
fi
SXMO_SUSPENDABLE_STATES="${SXMO_SUSPENDABLE_STATES:-screenoff 3}"
transition_can_suspend() {
@@ -54,11 +48,15 @@ transition_can_suspend() {
transition() {
state="$1"
# We don't transition if we stay with the same state
# shellcheck disable=SC2153
if [ "$state" = "$(cat "$SXMO_STATE")" ]; then
return
fi
sxmo_log "transitioning to stage $state"
printf %s "$state" > "$SXMO_STATE"
lock_shared
(
# We need a subshell so we can close the lock fd, without
# releasing the lock
@@ -97,7 +95,6 @@ click() {
else
transition "$state"
fi
flushstored
}
idle() {
@@ -119,75 +116,18 @@ idle() {
sxmo_log "idle: not transitioning from $state"
}
store() {
storeid="$(tr -dc 'a-zA-Z0-9' < /dev/urandom 2>/dev/null | head -c 10)"
printf %s "$state" > "$SXMO_STATE.stored.$storeid"
printf %s "$storeid"
}
flushstored() {
find "$(dirname "$SXMO_STATE")" -name 'sxmo.state.stored.*' -delete
}
restore() {
storeid="$1"
if [ -f "$SXMO_STATE.stored.$storeid" ]; then
state="$(cat "$SXMO_STATE.stored.$storeid")"
transition "$state"
flushstored
fi
}
exec 3<> "$SXMO_STATE.lock"
lock_exclusive() {
flock -x 3
}
lock_shared() {
flock -s 3
}
read_state() {
state="$(cat "$SXMO_STATE")"
}
action="$1"
shift
case "$action" in
click|idle)
lock_exclusive
read_state
"$action" "$@" ;;
get)
lock_shared
read_state
printf %s "$state"
;;
is_locked)
pidof peanutbutter swaylock waylock i3lock > /dev/null && exit 0
if sxmo_state.sh get | grep -q unlock; then
exit 1
fi
;;
click|idle) "$action" "$@" ;;
set)
lock_exclusive
read_state
if printf "%b\n" "$SXMO_STATES" | tr ' ' '\n' | grep -xq "$1"; then
transition "$1"
fi
;;
store)
lock_exclusive
read_state
store
;;
restore)
lock_exclusive
restore "$1"
;;
flushstored)
lock_exclusive
flushstored
;;
esac

View File

@@ -75,5 +75,7 @@ link_select() {
link_normalize "$(xprop -id "$SURF_WINDOW" _SURF_URI | cut -d '"' -f 2)"
}
sxmo_keyboard.sh open
VAL="$(link_select)"
sxmo_keyboard.sh close
echo "$VAL"

View File

@@ -21,26 +21,6 @@ if [ -n "$mnc" ] && [ "$mnc" -gt 0 ] && [ "$mnc" -lt "$YEARS8_TO_SEC" ]; then
fi
fi
if [ "$SXMO_DEVICE_NAME" = "google,b4s4-sdm670" ]; then #(google pixel 3a)
# Quoting Richard Acayan from: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/5400/ :
#
# There is a bug in FastRPC when waking from suspend. Since HexagonRPCD is
# currently only useful for a few moments when the ADSP is requesting the
# sensor registry, it can just be stopped without affecting sensor
# support. Add a pre-suspend hook to stop HexagonRPCD so it doesn't crash
# the ADSP when the device wakes up.
#
case "$SXMO_OS" in
alpine|postmarketos)
doas -n rc-service hexagonrpcd-adsp-sensorspd stop
;;
arch|archarm|nixos|debian)
doas -n systemctl stop hexagonrpcd-adsp-sensorspd
;;
esac
fi
sxmo_log "calling suspend with suspend_time <$suspend_time>"
start="$(date "+%s")"

View File

@@ -1,33 +0,0 @@
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2024 Sxmo Contributors
# Tabbed options for various programs
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
OPTIONS="
alacritty --embed
st -w
surf -e
urxvt -embed
zathura -e
"
LIST="$(grep . <<-EOF | sxmo_dmenu.sh -p "Tabbed Embed"
$OPTIONS
Nothing
Close
EOF
)"
case "$LIST" in
"Close"|"") exit 0 ;;
"Nothing") tabbed ;;
*)
# shellcheck disable=SC2086
tabbed $LIST
;;
esac

View File

@@ -15,9 +15,6 @@ case "$SXMO_TERMINAL" in
"st"*)
set -- $SXMO_TERMINAL -T "$TERMNAME" -e "$@"
;;
"tilix"*)
set -- $SXMO_TERMINAL -t "$TERMNAME" -e "$@"
;;
"foot"*)
set -- $SXMO_TERMINAL -T "$TERMNAME" "$@"
;;
@@ -25,13 +22,7 @@ case "$SXMO_TERMINAL" in
set -- ${SXMO_TERMINAL% --} --title "$TERMNAME" -- "$@"
;;
"alacritty"*)
# Test if alacritty was called with shell or a program
# Even with dynamic_title = true in config title will be static with -T switch
if [ "$*" = "$SHELL" ]; then
set -- $SXMO_TERMINAL
else
set -- $SXMO_TERMINAL -T "$TERMNAME" -e "$@"
fi
;;
*)
printf "%s: '%s'\n" "Not implemented for SXMO_TERMINAL" "$SXMO_TERMINAL" >&2

View File

@@ -30,7 +30,7 @@ menu() {
find "$zoneinfo_dir" -type f |
sed "s#^${zoneinfo_dir}/##g" |
sort |
sxmo_dmenu.sh -p Timezone -i
sxmo_dmenu_with_kb.sh -p Timezone -i
)" || exit 0
sxmo_terminal.sh "$0" "$T"
}

View File

@@ -38,7 +38,7 @@ pactl info
/usr/bin/mmcli --version | head -n 1
uname -m
. /etc/os-release
printf "%s %s\n" "$NAME" "$VERSION"
printf "%s %s" "$NAME" "$VERSION"
# shellcheck disable=SC2034
if [ "$1" = "--block" ]; then

View File

@@ -11,7 +11,6 @@ Usage: $(basename "$0") ACTION
isenabled
lock <lock-name> <duration|nanosec|infinite>
unlock <lock-name>
run <cmd...>
duration: <value><unit>
value: integer
unit: ms|s|mn|h (milisec, sec, minute, hour)
@@ -39,7 +38,8 @@ lock() {
case "$2" in
infinite)
sxmo_debug "lock $1 infinite"
set "$1"
echo "$1" | doas tee -a /sys/power/wake_lock > /dev/null
exit
;;
*ms)
_validint "${2%ms}"
@@ -59,13 +59,8 @@ lock() {
;;
esac
if [ -n "$2" ]; then
sxmo_debug "lock $1 $2"
echo "$1 $2" | doas tee -a /sys/power/wake_lock > /dev/null
else
sxmo_debug "lock $1 indefinitely"
echo "$1" | doas tee -a /sys/power/wake_lock > /dev/null
fi
}
unlock() {
@@ -93,30 +88,6 @@ case "$cmd" in
isenabled) isenabled "$@";;
lock) lock "$@";;
unlock) unlock "$@";;
run)
finish() {
if [ -n "$cmdpid" ]; then
kill "$cmdpid" 2> /dev/null
fi
unlock "sxmo_wakelock_$$"
exit
}
if isenabled; then
lock "sxmo_wakelock_$$" infinite
trap finish INT TERM EXIT
else
cat <<-EOF >&2
Warning: we can't wakelock, we can't make sure no suspension will occur...
EOF
fi
"$@" &
cmdpid=$!
wait "$cmdpid"
unset cmdpid
;;
*)
sxmo_log "warning: sxmo_wakelock.sh $*"
usage; exit 1;;

View File

@@ -7,7 +7,6 @@ envvars() {
export MOZ_ENABLE_WAYLAND=1
export SDL_VIDEODRIVER=wayland
export XDG_CURRENT_DESKTOP=sway
[ -z "$SXMO_MENU" ] && export SXMO_MENU=bemenu
# shellcheck disable=SC2086
command -v $SXMO_TERMINAL "" >/dev/null || export SXMO_TERMINAL="foot"
command -v "$KEYBOARD" >/dev/null || export KEYBOARD=wvkbd-mobintl
@@ -25,17 +24,7 @@ with_dbus() {
cleanup() {
sxmo_jobs.sh stop all
case "$SXMO_MENU" in
bemenu)
pkill bemenu
;;
wofi)
pkill wofi
;;
dmenu)
pkill dmenu
;;
esac
pkill wvkbd
pkill superd
}

View File

@@ -73,7 +73,7 @@ swayinputevent() {
# If we dont have any matching input
if ! swaymsg -t get_inputs \
| jq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" )" \
| gojq -r ".[] | select(.type == \"$TOUCH_POINTER_ID\" )" \
| grep -q .; then
if [ -z "$2" ]; then
@@ -103,7 +103,7 @@ swayinputevent() {
xorgfocusedwindow() {
activeoutput="$(xprop -id "$(xdotool getactivewindow 2>/dev/null)" 2>/dev/null)"
printf %s "$activeoutput" | \
grep ^WM_CLASS | cut -d" " -f3- | cut -d"," -f2 | \
grep ^WM_CLASS | cut -d" " -f3- | cut -d"," -f1 | \
xargs printf 'app: %s'
printf "\n"
printf %s "$activeoutput" | \
@@ -112,20 +112,27 @@ xorgfocusedwindow() {
}
swayfocusedwindow() {
swaymsg -t get_tree | jq -r '
TREE="$(swaymsg -t get_tree)"
FOCUS="$(
printf %s "$TREE" | jq -r '
recurse(.nodes[]) |
select(.focused == true) |
{
app_id: (if .app_id != null then
.app_id
else
.window_properties.class
end),
name: .name,
} |
select(.app_id != null and .name != null) |
select((.focused == true) and (.app_id != null)) |
{app_id: .app_id, name: .name} |
"app: " + .app_id, "title: " + .name
'
)"
if [ -z "$FOCUS" ]; then
#app_id is null, fall back to detect xwayland app:
FOCUS="$(
printf %s "$TREE" | jq -r '
recurse(.nodes[]) |
select((.focused == true) and (.shell == "xwayland")) |
{app_id: .window_properties.class, name: .window_properties.title} |
"app: " + .app_id, "title: " + .name
'
)"
fi
printf "%s\n" "$FOCUS"
}
swaypaste() {
@@ -144,7 +151,7 @@ swayexec() {
swayexecwait() {
PIDFILE="$(mktemp)"
printf '"%s" & printf %%s "$!" > "%s"' "$*" "$PIDFILE" \
| xargs -I{} swaymsg exec -- '{}'
| xargs -I{} swaymsg exec -- sh -c '{}'
while : ; do
sleep 0.5
kill -0 "$(cat "$PIDFILE")" 2> /dev/null || break

View File

@@ -2,27 +2,27 @@
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# This script is responsible for starting wob, or xob, and making sure it exits cleanly
# This script is responsible for starting wob, and making sure it exits cleanly
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
ob_sock="$XDG_RUNTIME_DIR"/sxmo.obsock
rm -f "$ob_sock"
mkfifo "$ob_sock"
wob_sock="$XDG_RUNTIME_DIR"/sxmo.wobsock
rm -f "$wob_sock"
mkfifo "$wob_sock"
# By opening the socket as read-write it isn't closed after the first write
# see https://unix.stackexchange.com/questions/392697
"${1:-wob}" <> "$ob_sock" &
OBPID=$!
wob <> "$wob_sock" &
WOBPID=$!
finish() {
# Only finish once
trap - TERM INT EXIT
kill "$OBPID"
rm -f "$ob_sock"
kill "$WOBPID"
rm -f "$wob_sock"
}
trap 'finish' TERM INT EXIT
wait "$OBPID"
wait "$WOBPID"

View File

@@ -8,9 +8,8 @@
envvars() {
export SXMO_WM=dwm
export XDG_CURRENT_DESKTOP=dwm
[ -z "$SXMO_MENU" ] && export SXMO_MENU=dmenu
# shellcheck disable=SC2086
command -v $SXMO_TERMINAL "" >/dev/null || export SXMO_TERMINAL="st"
command -v $SXMO_TERMINAL "" >/dev/null || export SXMO_TERMINAL="st -e"
command -v "$KEYBOARD" >/dev/null || defaultkeyboard
[ -z "$MOZ_USE_XINPUT2" ] && export MOZ_USE_XINPUT2=1
}
@@ -48,14 +47,7 @@ with_dbus() {
cleanup() {
sxmo_jobs.sh stop all
pkill svkbd
case "$SXMO_MENU" in
dmenu)
pkill dmenu
;;
bemenu)
pkill bemenu
;;
esac
pkill superd
}

View File

@@ -44,8 +44,16 @@ export SXMO_MODEM_GPIO_KEY_RI | If the modem driver handle a gpio, sxmo have to
export SXMO_NO_MODEM | Disable modem related features
### Screen-related
SXMO_ROTATION_POLL_TIME | Polling time for rotate in seconds (decimals allowed e.g. .1) [default: 1]
SXMO_ROTATION_GRAVITY | Override gravity for calculating rotation [default: 500]
SXMO_ROTATION_THRESHOLD | Threshold for detecting rotation [default: 60]
SXMO_MIN_BRIGHTNESS | Minimum brightness level [default: 5]
SXMO_DISABLE_LEDS | Disable leds (1 or 0) [default: 0]
SXMO_SWAY_SCALE | Screen scale for hidpi screens. Can be fractional [SWAY-ONLY].
SXMO_ROTATE_DIRECTION | The direction to rotate when using the gesture [default: right]
@@ -71,8 +79,6 @@ SXMO_DISABLE_KEYBINDS | Disable most custom Sxmo binds on volume keys if set.
SXMO_MONITOR | Display "Output" from `swaymsg -t get_outputs`. Should be the same as the output from the `xrandr` command when running dwm.
SXMO_NO_VIRTUAL_KEYBOARD | Disable all virtual keyboard management, and change some related gesture behavior.
### General / Misc.
SXMO_VIBRATE_DEV | Path to vibration device (see sxmo_vibrate.c and clickclack.c) [default: /dev/input/by-path/platform-vibrator-event]
SXMO_VIBRATE_STRENGTH | Strength parameter to pass to sxmo_vibrate [default: 1]

View File

@@ -1,8 +0,0 @@
#!/bin/sh
# Alcatel OneTouch Idol 3 (5.5) (6045Y)
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2024 Sxmo Contributors
export SXMO_VIBRATE_DEV="/dev/input/by-path/platform-200f000.spmi-platform-200f000.spmi:pmic@1:vibrator@c000-event"
export SXMO_MIN_BRIGHTNESS=1 # Still visible
export SXMO_VIBRATE_STRENGTH=256 # Is activated between 256 and 65535, from lowest to highest

View File

@@ -1 +0,0 @@
export SXMO_NO_MODEM=1

2
scripts/deviceprofiles/sxmo_deviceprofile_desktop.sh Executable file → Normal file
View File

@@ -1,6 +1,6 @@
export SXMO_DISABLE_LEDS=1
export SXMO_STATUS_DATE_FORMAT="%Y-%m-%d %H:%M"
export SXMO_DISABLE_KEYBINDS=1
export SXMO_STATES="unlock locker"
export SXMO_UNLOCK_IDLE_TIME=300
export SXMO_NO_MODEM=1
export SXMO_NO_VIRTUAL_KEYBOARD=1

View File

Some files were not shown because too many files have changed in this diff Show More