diff --git a/devices/nokia-argon/qcom-msm8905-nokia-argon.dtb b/devices/nokia-argon/qcom-msm8905-nokia-argon.dtb index 3927f65..8204f03 100644 Binary files a/devices/nokia-argon/qcom-msm8905-nokia-argon.dtb and b/devices/nokia-argon/qcom-msm8905-nokia-argon.dtb differ diff --git a/devices/nokia-argon/qcom-msm8905-nokia-argon.dts b/devices/nokia-argon/qcom-msm8905-nokia-argon.dts index 66066ee..84ec74b 100644 --- a/devices/nokia-argon/qcom-msm8905-nokia-argon.dts +++ b/devices/nokia-argon/qcom-msm8905-nokia-argon.dts @@ -945,6 +945,22 @@ phandle = <0x4f>; }; + sdc2-cd-on-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <0x02>; + bias-pull-up; + phandle = <0x90>; + }; + + sdc2-cd-off-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <0x02>; + bias-disable; + phandle = <0x91>; + }; + wcnss-active-state { pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44"; function = "wcss_wlan"; @@ -1524,13 +1540,13 @@ clocks = <0x14 0x82 0x14 0x81 0x18>; clock-names = "core", "iface", "xo"; pinctrl-names = "default", "sleep"; - pinctrl-0 = <0x4a 0x4b 0x4c>; - pinctrl-1 = <0x4d 0x4e 0x4f>; + pinctrl-0 = <0x4a 0x4b 0x4c 0x90>; + pinctrl-1 = <0x4d 0x4e 0x4f 0x91>; bus-width = <0x04>; status = "okay"; vmmc-supply = <0x50>; vqmmc-supply = <0x51>; - non-removable; + cd-gpios = <0x27 0x26 0x01>; }; dma-controller@7884000 { diff --git a/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb b/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb index beda68e..64e52d6 100644 Binary files a/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb and b/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dtb differ diff --git a/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts b/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts index 302aaa8..e8a1907 100644 --- a/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts +++ b/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts @@ -945,6 +945,22 @@ phandle = <0x4f>; }; + sdc2-cd-on-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <0x02>; + bias-pull-up; + phandle = <0x90>; + }; + + sdc2-cd-off-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <0x02>; + bias-disable; + phandle = <0x91>; + }; + wcnss-active-state { pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44"; function = "wcss_wlan"; @@ -1578,13 +1594,13 @@ clocks = <0x14 0x82 0x14 0x81 0x18>; clock-names = "core", "iface", "xo"; pinctrl-names = "default", "sleep"; - pinctrl-0 = <0x4a 0x4b 0x4c>; - pinctrl-1 = <0x4d 0x4e 0x4f>; + pinctrl-0 = <0x4a 0x4b 0x4c 0x90>; + pinctrl-1 = <0x4d 0x4e 0x4f 0x91>; bus-width = <0x04>; status = "okay"; vmmc-supply = <0x50>; vqmmc-supply = <0x51>; - non-removable; + cd-gpios = <0x27 0x26 0x01>; }; dma-controller@7884000 { diff --git a/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dtb b/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dtb index 757a605..e0f92ca 100644 Binary files a/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dtb and b/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dtb differ diff --git a/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts b/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts index b8b5d48..14a2a6a 100644 --- a/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts +++ b/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts @@ -949,6 +949,22 @@ phandle = <0x43>; }; + sdc2-cd-on-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <0x02>; + bias-pull-up; + phandle = <0x90>; + }; + + sdc2-cd-off-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <0x02>; + bias-disable; + phandle = <0x91>; + }; + wcnss-active-state { pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44"; function = "wcss_wlan"; @@ -1250,13 +1266,13 @@ clocks = <0x14 0x82 0x14 0x81 0x18>; clock-names = "core", "iface", "xo"; pinctrl-names = "default", "sleep"; - pinctrl-0 = <0x3e 0x3f 0x40>; - pinctrl-1 = <0x41 0x42 0x43>; + pinctrl-0 = <0x3e 0x3f 0x40 0x90>; + pinctrl-1 = <0x41 0x42 0x43 0x91>; bus-width = <0x04>; status = "okay"; vmmc-supply = <0x44>; vqmmc-supply = <0x45>; - non-removable; + cd-gpios = <0x27 0x26 0x01>; }; dma-controller@7884000 { diff --git a/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dtb b/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dtb index cc6d819..b27278f 100644 Binary files a/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dtb and b/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dtb differ diff --git a/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts b/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts index 9c1f778..7f2eea1 100644 --- a/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts +++ b/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts @@ -949,6 +949,22 @@ phandle = <0x43>; }; + sdc2-cd-on-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <0x02>; + bias-pull-up; + phandle = <0x90>; + }; + + sdc2-cd-off-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <0x02>; + bias-disable; + phandle = <0x91>; + }; + wcnss-active-state { pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44"; function = "wcss_wlan"; @@ -1250,13 +1266,13 @@ clocks = <0x14 0x82 0x14 0x81 0x18>; clock-names = "core", "iface", "xo"; pinctrl-names = "default", "sleep"; - pinctrl-0 = <0x3e 0x3f 0x40>; - pinctrl-1 = <0x41 0x42 0x43>; + pinctrl-0 = <0x3e 0x3f 0x40 0x90>; + pinctrl-1 = <0x41 0x42 0x43 0x91>; bus-width = <0x04>; status = "okay"; vmmc-supply = <0x44>; vqmmc-supply = <0x45>; - non-removable; + cd-gpios = <0x27 0x26 0x01>; }; dma-controller@7884000 { diff --git a/devices/nokia-tough/qcom-msm8905-nokia-coconut.dtb b/devices/nokia-tough/qcom-msm8905-nokia-coconut.dtb index 7b4e2c2..3707b12 100644 Binary files a/devices/nokia-tough/qcom-msm8905-nokia-coconut.dtb and b/devices/nokia-tough/qcom-msm8905-nokia-coconut.dtb differ diff --git a/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts b/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts index 112406b..9382539 100644 --- a/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts +++ b/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts @@ -945,6 +945,22 @@ phandle = <0x4f>; }; + sdc2-cd-on-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <0x02>; + bias-pull-up; + phandle = <0x90>; + }; + + sdc2-cd-off-state { + pins = "gpio38"; + function = "gpio"; + drive-strength = <0x02>; + bias-disable; + phandle = <0x91>; + }; + wcnss-active-state { pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44"; function = "wcss_wlan"; @@ -1578,13 +1594,13 @@ clocks = <0x14 0x82 0x14 0x81 0x18>; clock-names = "core", "iface", "xo"; pinctrl-names = "default", "sleep"; - pinctrl-0 = <0x4a 0x4b 0x4c>; - pinctrl-1 = <0x4d 0x4e 0x4f>; + pinctrl-0 = <0x4a 0x4b 0x4c 0x90>; + pinctrl-1 = <0x4d 0x4e 0x4f 0x91>; bus-width = <0x04>; status = "okay"; vmmc-supply = <0x50>; vqmmc-supply = <0x51>; - non-removable; + cd-gpios = <0x27 0x26 0x01>; }; dma-controller@7884000 { diff --git a/overlay/rootfs/etc/doas.d/50-sxmo.conf b/overlay/rootfs/etc/doas.d/50-sxmo.conf index 826b9be..a0fdd93 100644 --- a/overlay/rootfs/etc/doas.d/50-sxmo.conf +++ b/overlay/rootfs/etc/doas.d/50-sxmo.conf @@ -35,6 +35,8 @@ permit nopass :wheel as root cmd tee args /sys/module/leds_msm8905_torch/paramet permit nopass :wheel as root cmd /usr/bin/tee args /sys/module/leds_msm8905_torch/parameters/next_reboot_mode permit nopass :wheel as root cmd /usr/bin/sxmo_power.sh permit nopass :wheel as root cmd sxmo_power.sh +permit nopass :wheel as root cmd /usr/bin/sxmo_sdcard.sh +permit nopass :wheel as root cmd sxmo_sdcard.sh permit nopass :wheel as root cmd /usr/bin/plymouth args quit permit nopass :wheel as root cmd plymouth args quit permit nopass :wheel as root cmd rc-service args hexagonrpcd-adsp-sensorspd stop diff --git a/overlay/rootfs/etc/local.d/10-power-save.start b/overlay/rootfs/etc/local.d/10-power-save.start index 3b8481c..1f2605c 100755 --- a/overlay/rootfs/etc/local.d/10-power-save.start +++ b/overlay/rootfs/etc/local.d/10-power-save.start @@ -12,3 +12,8 @@ fi { echo 3000 > /proc/sys/vm/dirty_expire_centisecs; } 2>/dev/null || true { echo "1 4 1 4" > /proc/sys/kernel/printk; } 2>/dev/null || true +# Automount microSD card if present at boot +if [ -x /usr/bin/sxmo_sdcard.sh ]; then + /usr/bin/sxmo_sdcard.sh automount boot >/dev/null 2>&1 & +fi + diff --git a/overlay/rootfs/etc/udev/rules.d/88-bananarchy-sdcard.rules b/overlay/rootfs/etc/udev/rules.d/88-bananarchy-sdcard.rules new file mode 100644 index 0000000..995b31f --- /dev/null +++ b/overlay/rootfs/etc/udev/rules.d/88-bananarchy-sdcard.rules @@ -0,0 +1,4 @@ +# Automatically mount and unmount removable microSD cards (mmcblk1) at /media/sdcard +SUBSYSTEM=="block", KERNEL=="mmcblk1p[1-9]*", ACTION=="add", RUN+="/usr/bin/sxmo_sdcard.sh automount add %k" +SUBSYSTEM=="block", KERNEL=="mmcblk1", ATTR{partition}!="1", ENV{ID_FS_USAGE}=="filesystem", ACTION=="add", RUN+="/usr/bin/sxmo_sdcard.sh automount add %k" +SUBSYSTEM=="block", KERNEL=="mmcblk1*", ACTION=="remove", RUN+="/usr/bin/sxmo_sdcard.sh automount remove %k" diff --git a/overlay/rootfs/usr/bin/sxmo_sdcard.sh b/overlay/rootfs/usr/bin/sxmo_sdcard.sh new file mode 100755 index 0000000..961bb92 --- /dev/null +++ b/overlay/rootfs/usr/bin/sxmo_sdcard.sh @@ -0,0 +1,322 @@ +#!/bin/sh +# Bananarchy microSD card autodetection, automount, and GUI/dmenu mount manager + +export PATH="/home/user/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +MOUNT_POINT="/media/sdcard" +STATE_FILE="/tmp/sxmo_sdcard_mounted" +USER_UID="10000" +USER_GID="10000" + +notify_user() { + title="$1" + body="$2" + if command -v notify-send >/dev/null 2>&1; then + if [ "$(id -u)" -eq 0 ]; then + su - user -c "DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/10000/bus notify-send '$title' '$body'" >/dev/null 2>&1 & + else + DISPLAY="${DISPLAY:-:0}" notify-send "$title" "$body" >/dev/null 2>&1 & + fi + fi +} + +is_mounted() { + if command -v findmnt >/dev/null 2>&1; then + findmnt -rn "$MOUNT_POINT" >/dev/null 2>&1 + return $? + fi + grep -qs " $MOUNT_POINT " /proc/mounts +} + +find_sd_disk() { + if [ -b /dev/mmcblk1 ]; then + printf "/dev/mmcblk1\n" + return 0 + fi + for sysblk in /sys/block/mmcblk*; do + [ -e "$sysblk" ] || continue + bname="$(basename "$sysblk")" + [ "$bname" = "mmcblk0" ] && continue + case "$bname" in + *boot*|*rpmb*) continue ;; + esac + link="$(readlink -f "$sysblk" 2>/dev/null || true)" + case "$link" in + *7864900.sdhci*|*7864000.sdhci*|*mmc1*) + if [ -b "/dev/$bname" ]; then + printf "/dev/%s\n" "$bname" + return 0 + fi + ;; + esac + done + return 1 +} + +find_sd_part() { + req_dev="${1:-}" + if [ -n "$req_dev" ]; then + case "$req_dev" in + /dev/*) [ -b "$req_dev" ] && { printf "%s\n" "$req_dev"; return 0; } ;; + *) [ -b "/dev/$req_dev" ] && { printf "/dev/%s\n" "$req_dev"; return 0; } ;; + esac + fi + disk="$(find_sd_disk || true)" + [ -n "$disk" ] || return 1 + for p in "${disk}p1" "${disk}p2" "${disk}p3" "${disk}p4" "$disk"; do + if [ -b "$p" ]; then + if [ "$p" = "$disk" ] && [ -b "${disk}p1" ]; then + continue + fi + printf "%s\n" "$p" + return 0 + fi + done + return 1 +} + +probe_controller() { + if [ -b /dev/mmcblk1 ]; then + return 0 + fi + if [ -w /sys/bus/platform/drivers/sdhci_msm/unbind ]; then + if [ -e /sys/bus/platform/drivers/sdhci_msm/7864900.sdhci ]; then + printf "7864900.sdhci" > /sys/bus/platform/drivers/sdhci_msm/unbind 2>/dev/null || true + sleep 0.2 + fi + printf "7864900.sdhci" > /sys/bus/platform/drivers/sdhci_msm/bind 2>/dev/null || true + i=0 + while [ "$i" -lt 12 ]; do + [ -b /dev/mmcblk1 ] && return 0 + sleep 0.1 + i="$(( i + 1 ))" + done + fi + [ -b /dev/mmcblk1 ] +} + +do_mount() { + if [ "$(id -u)" -ne 0 ]; then + exec doas /usr/bin/sxmo_sdcard.sh mount "$@" + fi + + if is_mounted; then + printf "1\n" > "$STATE_FILE" 2>/dev/null || true + chmod 644 "$STATE_FILE" 2>/dev/null || true + printf "Already mounted at %s\n" "$MOUNT_POINT" + return 0 + fi + + part="$(find_sd_part "${1:-}" || true)" + if [ -z "$part" ]; then + probe_controller || true + part="$(find_sd_part "${1:-}" || true)" + fi + + if [ -z "$part" ] || [ ! -b "$part" ]; then + rm -f "$STATE_FILE" 2>/dev/null || true + printf "No SD card detected\n" >&2 + return 1 + fi + + mkdir -p "$MOUNT_POINT" 2>/dev/null || true + fstype="$(blkid -o value -s TYPE "$part" 2>/dev/null || true)" + + mounted_ok=0 + case "$fstype" in + vfat|fat|msdos) + if mount -t vfat -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},fmask=0022,dmask=0022,iocharset=utf8" "$part" "$MOUNT_POINT" 2>/dev/null || \ + mount -t vfat -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},fmask=0022,dmask=0022" "$part" "$MOUNT_POINT" 2>/dev/null; then + mounted_ok=1 + fi + ;; + exfat) + if mount -t exfat -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},fmask=0022,dmask=0022" "$part" "$MOUNT_POINT" 2>/dev/null || \ + mount -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID}" "$part" "$MOUNT_POINT" 2>/dev/null; then + mounted_ok=1 + fi + ;; + ntfs|ntfs3) + if mount -t ntfs3 -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},umask=0022" "$part" "$MOUNT_POINT" 2>/dev/null || \ + mount -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID}" "$part" "$MOUNT_POINT" 2>/dev/null; then + mounted_ok=1 + fi + ;; + ext4|ext3|ext2|f2fs|btrfs|xfs) + if mount -o "rw,nosuid,nodev,noatime" "$part" "$MOUNT_POINT" 2>/dev/null; then + mounted_ok=1 + chown "${USER_UID}:${USER_GID}" "$MOUNT_POINT" 2>/dev/null || true + fi + ;; + *) + if mount -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID}" "$part" "$MOUNT_POINT" 2>/dev/null || \ + mount -o "rw,nosuid,nodev,noatime" "$part" "$MOUNT_POINT" 2>/dev/null; then + mounted_ok=1 + fi + ;; + esac + + if [ "$mounted_ok" -eq 1 ] && is_mounted; then + printf "1\n" > "$STATE_FILE" 2>/dev/null || true + chmod 644 "$STATE_FILE" 2>/dev/null || true + if [ ! -e /home/user/sdcard ]; then + ln -s "$MOUNT_POINT" /home/user/sdcard 2>/dev/null || true + chown -h "${USER_UID}:${USER_GID}" /home/user/sdcard 2>/dev/null || true + fi + notify_user "SD Card" "Mounted $(basename "$part") at $MOUNT_POINT" + printf "Mounted %s at %s\n" "$part" "$MOUNT_POINT" + return 0 + fi + + rm -f "$STATE_FILE" 2>/dev/null || true + printf "Failed to mount %s\n" "$part" >&2 + return 1 +} + +do_unmount() { + if [ "$(id -u)" -ne 0 ]; then + exec doas /usr/bin/sxmo_sdcard.sh unmount "$@" + fi + + sync + if ! is_mounted; then + rm -f "$STATE_FILE" 2>/dev/null || true + printf "SD card is not mounted\n" + return 0 + fi + + if umount "$MOUNT_POINT" 2>/dev/null || umount -l "$MOUNT_POINT" 2>/dev/null; then + rm -f "$STATE_FILE" 2>/dev/null || true + notify_user "SD Card" "Safely unmounted $MOUNT_POINT" + printf "Unmounted %s\n" "$MOUNT_POINT" + return 0 + fi + + printf "Failed to unmount %s (device busy)\n" "$MOUNT_POINT" >&2 + return 1 +} + +do_rescan() { + if [ "$(id -u)" -ne 0 ]; then + exec doas /usr/bin/sxmo_sdcard.sh rescan + fi + probe_controller || true + if find_sd_part >/dev/null 2>&1; then + do_mount + return $? + fi + rm -f "$STATE_FILE" 2>/dev/null || true + notify_user "SD Card" "No SD card detected in slot" + printf "No SD card detected\n" >&2 + return 1 +} + +do_status() { + if is_mounted; then + printf "1\n" > "$STATE_FILE" 2>/dev/null || true + dev="$(findmnt -rn -o SOURCE "$MOUNT_POINT" 2>/dev/null || printf "/dev/mmcblk1p1")" + fstype="$(findmnt -rn -o FSTYPE "$MOUNT_POINT" 2>/dev/null || printf "auto")" + df_line="$(df -h "$MOUNT_POINT" 2>/dev/null | awk 'NR==2 {print $2, $3, $4, $5}')" + printf "mounted %s %s %s %s\n" "$MOUNT_POINT" "$dev" "$fstype" "$df_line" + return 0 + fi + rm -f "$STATE_FILE" 2>/dev/null || true + part="$(find_sd_part 2>/dev/null || true)" + if [ -n "$part" ]; then + fstype="$(blkid -o value -s TYPE "$part" 2>/dev/null || printf "unknown")" + size="$(lsblk -dn -o SIZE "$part" 2>/dev/null | tr -d ' ' || printf "?")" + printf "unmounted %s %s %s\n" "$part" "$fstype" "$size" + return 0 + fi + printf "absent\n" + return 0 +} + +do_menu() { + . sxmo_hook_icons.sh + . sxmo_common.sh + + while : ; do + st="$(do_status)" + state_word="$(printf "%s" "$st" | awk '{print $1}')" + case "$state_word" in + mounted) + dev="$(printf "%s" "$st" | awk '{print $3}')" + free_sp="$(printf "%s" "$st" | awk '{print $7}')" + tot_sp="$(printf "%s" "$st" | awk '{print $5}')" + hdr="${icon_ton} Mounted: $(basename "$dev") (${free_sp:-?} free / ${tot_sp:-?})" + ;; + unmounted) + dev="$(printf "%s" "$st" | awk '{print $2}')" + sz="$(printf "%s" "$st" | awk '{print $4}')" + hdr="${icon_tof} Unmounted: $(basename "$dev") (${sz:-?})" + ;; + *) + hdr="${icon_tof} Status: No SD card detected" + ;; + esac + + CHOICES="$(cat </dev/null || true + +case "$cmd" in + status) + do_status + ;; + is_mounted|ismounted) + is_mounted + ;; + is_present|ispresent) + find_sd_part >/dev/null 2>&1 + ;; + mount) + do_mount "$@" + ;; + unmount|umount|eject) + do_unmount "$@" + ;; + rescan|detect|probe) + do_rescan + ;; + automount) + act="${1:-add}" + kname="${2:-}" + case "$act" in + add|boot) + if [ -n "$kname" ]; then + do_mount "/dev/$kname" >/dev/null 2>&1 || true + else + if find_sd_part >/dev/null 2>&1; then + do_mount >/dev/null 2>&1 || true + fi + fi + ;; + remove) + if [ "$(id -u)" -eq 0 ]; then + umount -l "$MOUNT_POINT" 2>/dev/null || true + rm -f "$STATE_FILE" 2>/dev/null || true + notify_user "SD Card" "SD card removed" + fi + ;; + esac + ;; + menu|*) + do_menu + ;; +esac diff --git a/overlay/rootfs/usr/lib/dwm/plugins/dmenu.so b/overlay/rootfs/usr/lib/dwm/plugins/dmenu.so index e770065..844655f 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/dmenu.so and b/overlay/rootfs/usr/lib/dwm/plugins/dmenu.so differ diff --git a/overlay/rootfs/usr/lib/dwm/plugins/files.so b/overlay/rootfs/usr/lib/dwm/plugins/files.so index 7c501ee..723331b 100755 Binary files a/overlay/rootfs/usr/lib/dwm/plugins/files.so and b/overlay/rootfs/usr/lib/dwm/plugins/files.so differ diff --git a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-argon.dtb b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-argon.dtb index b036121..8204f03 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-argon.dtb and b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-argon.dtb differ diff --git a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb index 115929b..64e52d6 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb and b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb differ diff --git a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb index cdf8d16..3707b12 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb and b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb differ diff --git a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-leo.dtb b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-leo.dtb index c2950eb..e0f92ca 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-leo.dtb and b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-leo.dtb differ diff --git a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-sparkler.dtb b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-sparkler.dtb index 57c33ba..b27278f 100644 Binary files a/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-sparkler.dtb and b/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-sparkler.dtb differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so index e770065..844655f 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/dmenu.so differ diff --git a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/files.so b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/files.so index 7c501ee..723331b 100755 Binary files a/prebuilt/sxmo-x11/usr/lib/dwm/plugins/files.so and b/prebuilt/sxmo-x11/usr/lib/dwm/plugins/files.so differ diff --git a/scripts/build-kernel-audio.sh b/scripts/build-kernel-audio.sh index 2b3afc7..83675d3 100755 --- a/scripts/build-kernel-audio.sh +++ b/scripts/build-kernel-audio.sh @@ -139,15 +139,16 @@ EOF M=/bananarchy/src/leds-msm8905-torch clean make ARCH=arm CROSS_COMPILE=armv7-alpine-linux-musleabihf- \ M=/bananarchy/src/msm8905-cam clean - cp -a arch/arm/boot/dts/qcom/qcom-msm8905-nokia-argon.dtb \ - arch/arm/boot/dts/qcom/qcom-msm8909-nokia-sparkler.dtb \ - arch/arm/boot/dts/qcom/qcom-msm8909-nokia-leo.dtb \ - /bananarchy/prebuilt/kernel-6.12.1-msm8916/dtbs/ - - dtc -I dts -O dtb -o /bananarchy/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb \ - /bananarchy/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts 2>/dev/null - dtc -I dts -O dtb -o /bananarchy/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb \ - /bananarchy/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts 2>/dev/null + for dts in \ + /bananarchy/devices/nokia-argon/qcom-msm8905-nokia-argon.dts \ + /bananarchy/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts \ + /bananarchy/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts \ + /bananarchy/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts \ + /bananarchy/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts; do + dtb="${dts%.dts}.dtb" + dtc -I dts -O dtb -o "$dtb" "$dts" 2>/dev/null + cp -a "$dtb" /bananarchy/prebuilt/kernel-6.12.1-msm8916/dtbs/ + done chown -R "$HOST_UID:$HOST_GID" /bananarchy/prebuilt/kernel-6.12.1-msm8916 \ /bananarchy/src/leds-msm8905-torch \ diff --git a/src/dwm-plugins/files_plugin.cpp b/src/dwm-plugins/files_plugin.cpp index 7247dca..99e3266 100644 --- a/src/dwm-plugins/files_plugin.cpp +++ b/src/dwm-plugins/files_plugin.cpp @@ -750,10 +750,22 @@ int runFilesApp(int argc, char** argv) { statusBannerUntilMs = nowMs() + 2200; }; + auto isSdCardMounted = []() -> bool { + std::ifstream f("/proc/mounts"); + std::string line; + while (std::getline(f, line)) { + if (line.find(" /media/sdcard ") != std::string::npos) { + return true; + } + } + return false; + }; + auto buildActionsList = [&]() { actionsList.clear(); bool hasSel = !filteredItems.empty(); bool isParent = hasSel && filteredItems[selected].isParent; + bool sdMounted = isSdCardMounted(); if (hasSel) { if (!filteredItems[selected].isDir) { @@ -807,6 +819,14 @@ int runFilesApp(int argc, char** argv) { else if (sortMode == SortMode::Date) sortLbl += "Size (#)"; else sortLbl += "Name (#)"; actionsList.push_back({11, kIconSort, sortLbl}); + if (sdMounted) { + if (currentDir != "/media/sdcard") { + actionsList.push_back({18, kIconFolderOpen, "Open SD Card (/media/sdcard)"}); + } + actionsList.push_back({19, kIconOutCall, "Unmount / Eject SD Card"}); + } else { + actionsList.push_back({20, kIconFolder, "Mount SD Card (/media/sdcard)"}); + } actionsList.push_back({12, kIconTerm, "Open Terminal Here"}); actionSelected = 0; }; @@ -1667,6 +1687,34 @@ int runFilesApp(int argc, char** argv) { filteredItems[selected].name); } else if (actId == 17 && !filteredItems.empty()) { openTextViewer(filteredItems[selected]); + } else if (actId == 18) { + loadDirectory("/media/sdcard"); + mode = ViewMode::Browser; + } else if (actId == 19) { + if (currentDir.rfind("/media/sdcard", 0) == 0) { + loadDirectory(homeDir); + } + int rc = std::system("sxmo_sdcard.sh unmount >/dev/null 2>&1"); + loadDirectory(currentDir); + statusBanner = (rc == 0 && !isSdCardMounted()) + ? "SD card unmounted" + : "Unmount failed (busy)"; + statusBannerUntilMs = nowMs() + 2200; + mode = ViewMode::Browser; + } else if (actId == 20) { + mode = ViewMode::Browser; + statusBanner = "Scanning SD card slot..."; + statusBannerUntilMs = nowMs() + 2500; + drawUI(); + int rc = std::system("sxmo_sdcard.sh mount >/dev/null 2>&1"); + if (rc == 0 && isSdCardMounted()) { + loadDirectory("/media/sdcard"); + statusBanner = "SD card mounted"; + } else { + loadDirectory(currentDir); + statusBanner = "No SD card detected"; + } + statusBannerUntilMs = nowMs() + 2200; } }; diff --git a/src/sxmo-dmenu/dmenu.c b/src/sxmo-dmenu/dmenu.c index ff98581..30c3edf 100644 --- a/src/sxmo-dmenu/dmenu.c +++ b/src/sxmo-dmenu/dmenu.c @@ -966,6 +966,24 @@ write_str_file(const char *path, const char *val) return n > 0; } +static int +sdcard_is_mounted_fast(void) +{ + FILE *fp = fopen("/proc/mounts", "r"); + if (!fp) + return 0; + char line[512]; + int mounted = 0; + while (fgets(line, sizeof(line), fp)) { + if (strstr(line, " /media/sdcard ") != NULL) { + mounted = 1; + break; + } + } + fclose(fp); + return mounted; +} + static int dunst_window_visible(void) { @@ -2365,6 +2383,9 @@ open_builtin_menu(const char *menu_name, int keep_idx) snprintf(label, sizeof(label), "%s Files", ICON_DIR); add_menu_item(label, "@plugin:files", 0); + snprintf(label, sizeof(label), "%s SD Card %s", ICON_DIR, sdcard_is_mounted_fast() ? ICON_TON : ICON_TOF); + add_menu_item(label, "@menu:sdcard", 1); + snprintf(label, sizeof(label), "%s Dialer", ICON_PHN); add_menu_item(label, "@plugin:dialer", 0); @@ -2610,6 +2631,26 @@ open_builtin_menu(const char *menu_name, int keep_idx) snprintf(label, sizeof(label), "%s Back to Config", ICON_CFG); add_menu_item(label, "@menu:config", 1); populate_timezone_menu(); + } else if (strcmp(menu_name, "sdcard") == 0) { + reset_session_defaults(1, "SD Card"); + append_active_call_entries(); + int mounted = sdcard_is_mounted_fast(); + snprintf(label, sizeof(label), "%s Status: %s %s", ICON_DIR, + mounted ? "Mounted (/media/sdcard)" : "Unmounted", + mounted ? ICON_TON : ICON_TOF); + add_menu_item(label, mounted ? "sxmo_sdcard.sh unmount >/dev/null 2>&1" : "sxmo_sdcard.sh mount >/dev/null 2>&1", 1); + snprintf(label, sizeof(label), "%s Open SD Card in Files", ICON_DIR); + add_menu_item(label, "@plugin:files:/media/sdcard", 0); + snprintf(label, sizeof(label), "%s Mount SD Card", ICON_DIR); + add_menu_item(label, "sxmo_sdcard.sh mount >/dev/null 2>&1", 1); + snprintf(label, sizeof(label), "%s Unmount / Eject SD Card", ICON_OUT); + add_menu_item(label, "sxmo_sdcard.sh unmount >/dev/null 2>&1", 1); + snprintf(label, sizeof(label), "%s Rescan SD Card Slot", ICON_RLD); + add_menu_item(label, "sxmo_sdcard.sh rescan >/dev/null 2>&1", 1); + snprintf(label, sizeof(label), "%s System Menu", ICON_MNU); + add_menu_item(label, "@menu:sys", 1); + snprintf(label, sizeof(label), "%s Close Menu", ICON_CLS); + add_menu_item(label, "@close", 0); } else if (strcmp(menu_name, "config") == 0) { reset_session_defaults(1, "Config"); append_active_call_entries(); @@ -2631,6 +2672,9 @@ open_builtin_menu(const char *menu_name, int keep_idx) snprintf(label, sizeof(label), "%s Bluetooth %s", ICON_BTH, bt_is_unblocked_fast() ? ICON_TON : ICON_TOF); add_menu_item(label, "@toggle:bluetooth", 1); + snprintf(label, sizeof(label), "%s SD Card %s", ICON_DIR, sdcard_is_mounted_fast() ? ICON_TON : ICON_TOF); + add_menu_item(label, "@menu:sdcard", 1); + snprintf(label, sizeof(label), "%s Change Timezone", ICON_CLK); add_menu_item(label, "@menu:timezone", 1);