Add NeoNet Yabasic networking FFI library, fix fcitx5 service and WM context menus, install yabasic-doc and mandoc
This commit is contained in:
1 parent
fb3723fab4
commit
726500085a
33 files changed
+2617
-69
No files matched your search
File diff suppressed because it is too large.
Load diff
+629
@@ -0,0 +1,629 @@
|
||||
#!/usr/bin/yabasic
|
||||
// ============================================================================
|
||||
// neonet_demo.yab - Bananarchy NeoNet + NeoUI Showcase for Yabasic
|
||||
// ============================================================================
|
||||
// Demonstrates combining NeoNet (libcurl + socket FFI) with NeoUI (240x320 UI):
|
||||
// - Tab 1 (1:HTTP/S): HTTP/HTTPS GET, POST, and HEAD requests with custom
|
||||
// headers, status code badge, server/IP inspection, and scrollable output
|
||||
// - Tab 2 (2:Sockets): Raw TLS (port 443), TCP (port 43 WHOIS), and binary
|
||||
// UDP (port 53 DNS A-record) socket data exchange
|
||||
// - Tab 3 (3:Tools): URL encode/decode, file download to /tmp, TLS verify
|
||||
// toggle, and libcurl version/capability inspection
|
||||
//
|
||||
// Controls:
|
||||
// - 1 / 2 / 3 (when not typing in an input box): Switch tabs
|
||||
// - Up / Down: Navigate controls or scroll response viewer
|
||||
// - Left / Right: Cycle HTTP method / socket protocol or switch tabs
|
||||
// - OK (Enter): Execute request / toggle option / edit input
|
||||
// - Left Softkey (F1): Open Presets & Actions menu
|
||||
// - Right Softkey (F2) / Backspace: Delete char (in input) or Quit
|
||||
// - Both Softkeys together: Open Bananarchy XDrawer overlay
|
||||
// ============================================================================
|
||||
|
||||
import neoui
|
||||
import neonet
|
||||
|
||||
if neoui_init("neonet_demo", 0) = 0 then
|
||||
print "Failed to initialize NeoUI X11 window"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
r = neonet_init()
|
||||
r = neonet_set_timeout(10000)
|
||||
r = neonet_set_connect_timeout(6000)
|
||||
|
||||
// Active tab: 0 = HTTP/S, 1 = Sockets, 2 = Tools & Info
|
||||
active_tab = 0
|
||||
|
||||
// Tab 0 (HTTP/S) state
|
||||
http_focus = 2
|
||||
http_url$ = "https://example.com/"
|
||||
http_method_idx = 0
|
||||
dim http_methods$(3)
|
||||
http_methods$(0) = "GET"
|
||||
http_methods$(1) = "POST"
|
||||
http_methods$(2) = "HEAD"
|
||||
custom_hdr_on = 1
|
||||
custom_hdr$ = "X-Bananarchy: NeoNet-1.0|Accept: */*"
|
||||
show_raw_headers = 0
|
||||
http_status_str$ = "Ready (press OK on Send)"
|
||||
http_meta_str$ = "Custom Header: X-Bananarchy"
|
||||
http_output$ = "Press OK on [Send] or open Left Softkey Menu for presets."
|
||||
http_scroll = 0
|
||||
|
||||
// Tab 1 (Sockets) state
|
||||
sock_focus = 2
|
||||
sock_proto_idx = 0
|
||||
dim sock_protos$(3)
|
||||
sock_protos$(0) = "TLS :443 (HTTPS Raw)"
|
||||
sock_protos$(1) = "TCP :43 (IANA WHOIS)"
|
||||
sock_protos$(2) = "UDP :53 (DNS Query)"
|
||||
sock_host$ = "example.com"
|
||||
sock_status_str$ = "Ready (select protocol & Run)"
|
||||
sock_output$ = "Supports raw TLS, TCP, and UDP socket data exchange."
|
||||
sock_scroll = 0
|
||||
|
||||
// Tab 2 (Tools) state
|
||||
tool_focus = 0
|
||||
tls_insecure = 0
|
||||
sample_raw$ = "Bananarchy 240x320 & NeoNet!"
|
||||
sample_enc$ = neonet_url_encode$(sample_raw$)
|
||||
dl_status$ = "Not downloaded yet"
|
||||
|
||||
// Modal state: 0 = None, 1 = Presets Menu
|
||||
modal_mode = 0
|
||||
menu_sel = 0
|
||||
|
||||
// Track which input box owns multi-tap buffer (0 = http_url$, 1 = sock_host$)
|
||||
active_input_owner = -1
|
||||
|
||||
sub sync_input_box(owner_id)
|
||||
if active_input_owner = owner_id then
|
||||
return
|
||||
fi
|
||||
active_input_owner = owner_id
|
||||
if owner_id = 0 then
|
||||
neoui_input_reset(http_url$)
|
||||
elsif owner_id = 1 then
|
||||
neoui_input_reset(sock_host$)
|
||||
fi
|
||||
end sub
|
||||
|
||||
sub save_input_box()
|
||||
if active_input_owner = 0 then
|
||||
neoui_input_commit_tap()
|
||||
http_url$ = neoui_input_get_text$()
|
||||
elsif active_input_owner = 1 then
|
||||
neoui_input_commit_tap()
|
||||
sock_host$ = neoui_input_get_text$()
|
||||
fi
|
||||
end sub
|
||||
|
||||
sub sanitize_display_text$(s$, max_chars)
|
||||
local out$, n, i, ch$, code
|
||||
n = len(s$)
|
||||
if n > max_chars then
|
||||
n = max_chars
|
||||
fi
|
||||
out$ = ""
|
||||
for i = 1 to n
|
||||
ch$ = mid$(s$, i, 1)
|
||||
code = asc(ch$)
|
||||
if code = 10 or (code >= 32 and code <= 126) then
|
||||
out$ = out$ + ch$
|
||||
elsif code = 9 then
|
||||
out$ = out$ + " "
|
||||
fi
|
||||
next i
|
||||
return out$
|
||||
end sub
|
||||
|
||||
sub run_http_request()
|
||||
local m$, hdrs$, body$, st, blen, srv$, ip$
|
||||
save_input_box()
|
||||
m$ = http_methods$(http_method_idx)
|
||||
if custom_hdr_on then
|
||||
hdrs$ = custom_hdr$
|
||||
else
|
||||
hdrs$ = ""
|
||||
fi
|
||||
|
||||
neoui_show_toast(m$ + " " + http_url$ + " ...", 500)
|
||||
render_all()
|
||||
neoui_flush()
|
||||
|
||||
if m$ = "GET" then
|
||||
body$ = neonet_get_ex$(http_url$, hdrs$)
|
||||
elsif m$ = "POST" then
|
||||
body$ = neonet_post$(http_url$, "{\"device\":\"nokia-argon\",\"sdk\":\"NeoNet\"}", "application/json", hdrs$)
|
||||
else
|
||||
st = neonet_head(http_url$, hdrs$)
|
||||
body$ = neonet_response_headers$()
|
||||
fi
|
||||
|
||||
st = neonet_status()
|
||||
blen = neonet_body_len()
|
||||
http_scroll = 0
|
||||
|
||||
if neonet_last_code() <> 0 then
|
||||
http_status_str$ = "ERR (" + str$(neonet_last_code()) + "): " + neonet_error$()
|
||||
http_meta_str$ = "URL: " + http_url$
|
||||
http_output$ = "Request failed: " + neonet_error$()
|
||||
neoui_show_toast("HTTP error!", 1600)
|
||||
else
|
||||
srv$ = neonet_header$("server")
|
||||
if srv$ = "" then
|
||||
srv$ = "n/a"
|
||||
fi
|
||||
ip$ = neonet_primary_ip$()
|
||||
http_status_str$ = m$ + " -> HTTP " + str$(st) + " (" + str$(blen) + " B)"
|
||||
http_meta_str$ = "IP: " + ip$ + " Srv: " + srv$
|
||||
if show_raw_headers or m$ = "HEAD" then
|
||||
http_output$ = sanitize_display_text$(neonet_response_headers$(), 1800)
|
||||
else
|
||||
http_output$ = sanitize_display_text$(body$, 1800)
|
||||
fi
|
||||
neoui_show_toast("HTTP " + str$(st) + " (" + str$(blen) + " B)", 1500)
|
||||
fi
|
||||
end sub
|
||||
|
||||
sub run_socket_exchange()
|
||||
local crlf$, req$, rx$, ip$, dns_srv$
|
||||
save_input_box()
|
||||
crlf$ = chr$(13) + chr$(10)
|
||||
sock_scroll = 0
|
||||
|
||||
if sock_proto_idx = 0 then
|
||||
neoui_show_toast("TLS connect " + sock_host$ + ":443 ...", 500)
|
||||
render_all()
|
||||
neoui_flush()
|
||||
|
||||
req$ = "HEAD / HTTP/1.1" + crlf$ + "Host: " + sock_host$ + crlf$ + "User-Agent: NeoNet-TLS/1.0" + crlf$ + "Connection: close" + crlf$ + crlf$
|
||||
rx$ = neonet_tls_exchange$(sock_host$, 443, req$, 4000)
|
||||
if rx$ = "" and neonet_error$() <> "" then
|
||||
sock_status_str$ = "TLS Error: " + neonet_error$()
|
||||
sock_output$ = "Could not complete TLS exchange with " + sock_host$ + ":443"
|
||||
neoui_show_toast("TLS failed", 1500)
|
||||
else
|
||||
sock_status_str$ = "TLS :443 OK (" + str$(neonet_last_len()) + " B recv)"
|
||||
sock_output$ = sanitize_display_text$(rx$, 1800)
|
||||
neoui_show_toast("TLS recv " + str$(neonet_last_len()) + " B", 1500)
|
||||
fi
|
||||
|
||||
elsif sock_proto_idx = 1 then
|
||||
neoui_show_toast("TCP connect whois.iana.org:43 ...", 500)
|
||||
render_all()
|
||||
neoui_flush()
|
||||
|
||||
rx$ = neonet_tcp_exchange$("whois.iana.org", 43, sock_host$ + crlf$, 4000)
|
||||
if rx$ = "" and neonet_error$() <> "" then
|
||||
sock_status_str$ = "TCP Error: " + neonet_error$()
|
||||
sock_output$ = "Could not query whois.iana.org:43"
|
||||
neoui_show_toast("TCP failed", 1500)
|
||||
else
|
||||
sock_status_str$ = "TCP :43 OK (" + str$(neonet_last_len()) + " B recv)"
|
||||
sock_output$ = sanitize_display_text$(rx$, 1800)
|
||||
neoui_show_toast("TCP recv " + str$(neonet_last_len()) + " B", 1500)
|
||||
fi
|
||||
|
||||
else
|
||||
dns_srv$ = neonet_system_dns$()
|
||||
neoui_show_toast("UDP DNS @" + dns_srv$ + ":53 ...", 500)
|
||||
render_all()
|
||||
neoui_flush()
|
||||
|
||||
ip$ = neonet_udp_dns_a$(dns_srv$, sock_host$, 3000)
|
||||
if ip$ = "" then
|
||||
sock_status_str$ = "UDP DNS Error: " + neonet_error$()
|
||||
sock_output$ = "Resolver: " + dns_srv$ + ":53\nQuery: " + sock_host$ + "\nError: " + neonet_error$()
|
||||
neoui_show_toast("UDP DNS failed", 1500)
|
||||
else
|
||||
sock_status_str$ = "UDP :53 -> " + ip$
|
||||
sock_output$ = "Protocol: RFC 1035 Binary UDP Datagram\nServer: " + dns_srv$ + ":53\nQuestion: " + sock_host$ + " (IN A)\nResolved IPv4: " + ip$ + "\nPacket Size: " + str$(neonet_last_len()) + " bytes"
|
||||
neoui_show_toast(sock_host$ + " -> " + ip$, 1800)
|
||||
fi
|
||||
fi
|
||||
end sub
|
||||
|
||||
sub render_http_tab()
|
||||
local url_disp$, hdr_state$, view_lbl$
|
||||
if http_focus = 0 then
|
||||
sync_input_box(0)
|
||||
url_disp$ = neoui_input_get_text$()
|
||||
else
|
||||
url_disp$ = http_url$
|
||||
fi
|
||||
|
||||
neoui_draw_input_box(6, 60, 228, 36, http_focus = 0, "Target URL [" + http_methods$(http_method_idx) + "]", url_disp$, "https://...", 0)
|
||||
|
||||
if custom_hdr_on then
|
||||
hdr_state$ = "ON"
|
||||
else
|
||||
hdr_state$ = "OFF"
|
||||
fi
|
||||
neoui_draw_toggle_row(0, 98, 28, http_focus = 1, neoui_icon$("edit"), neoui.TEXT_BLUE, "Hdr: X-Bananarchy", custom_hdr_on, hdr_state$)
|
||||
|
||||
if show_raw_headers then
|
||||
view_lbl$ = "Show:Hdrs"
|
||||
else
|
||||
view_lbl$ = "Show:Body"
|
||||
fi
|
||||
neoui_draw_button(6, 128, 72, 22, http_focus = 2, 0, neoui_icon$("globe"), "Send")
|
||||
neoui_draw_button(84, 128, 72, 22, http_focus = 3, 0, neoui_icon$("sort"), "Method")
|
||||
neoui_draw_button(162, 128, 72, 22, http_focus = 4, 0, neoui_icon$("eye"), view_lbl$)
|
||||
|
||||
neoui_fill_rect(6, 153, 228, 114, neoui_color(neoui.COLOR_BG_ALT_ODD))
|
||||
if http_focus = 5 then
|
||||
neoui_draw_rect(6, 153, 228, 114, neoui_color(neoui.COLOR_ACCENT))
|
||||
else
|
||||
neoui_draw_rect(6, 153, 228, 114, neoui_color(neoui.COLOR_BORDER))
|
||||
fi
|
||||
|
||||
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_GREEN, 10, 155, 14, http_status_str$, 220)
|
||||
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_YELLOW, 10, 169, 14, http_meta_str$, 220)
|
||||
neoui_draw_line(8, 184, 232, 184, neoui_color(neoui.COLOR_DIVIDER))
|
||||
neoui_draw_text_wrapped(neoui.FONT_SMALL, neoui.TEXT_LIGHT, 10, 186, 220, 78, http_output$, http_scroll)
|
||||
|
||||
if http_focus = 0 then
|
||||
neoui_draw_multitap_bar(0, 248, 240, 22, "0-9:Type 1:Sym #:Mode OK:Send")
|
||||
fi
|
||||
end sub
|
||||
|
||||
sub render_sockets_tab()
|
||||
local host_disp$
|
||||
if sock_focus = 1 then
|
||||
sync_input_box(1)
|
||||
host_disp$ = neoui_input_get_text$()
|
||||
else
|
||||
host_disp$ = sock_host$
|
||||
fi
|
||||
|
||||
neoui_draw_list_row(0, 60, 30, sock_focus = 0, neoui_icon$("wifi"), neoui.TEXT_YELLOW, sock_protos$(sock_proto_idx), "", "< >")
|
||||
neoui_draw_input_box(6, 92, 228, 36, sock_focus = 1, "Host / Domain", host_disp$, "example.com", 0)
|
||||
|
||||
neoui_draw_button(6, 130, 140, 22, sock_focus = 2, 0, neoui_icon$("check"), "Run Exchange")
|
||||
neoui_draw_button(152, 130, 82, 22, sock_focus = 3, 0, neoui_icon$("refresh"), "Clear")
|
||||
|
||||
neoui_fill_rect(6, 155, 228, 112, neoui_color(neoui.COLOR_BG_ALT_ODD))
|
||||
if sock_focus = 4 then
|
||||
neoui_draw_rect(6, 155, 228, 112, neoui_color(neoui.COLOR_ACCENT))
|
||||
else
|
||||
neoui_draw_rect(6, 155, 228, 112, neoui_color(neoui.COLOR_BORDER))
|
||||
fi
|
||||
|
||||
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_GREEN, 10, 157, 15, sock_status_str$, 220)
|
||||
neoui_draw_line(8, 173, 232, 173, neoui_color(neoui.COLOR_DIVIDER))
|
||||
neoui_draw_text_wrapped(neoui.FONT_SMALL, neoui.TEXT_LIGHT, 10, 175, 220, 90, sock_output$, sock_scroll)
|
||||
|
||||
if sock_focus = 1 then
|
||||
neoui_draw_multitap_bar(0, 248, 240, 22, "0-9:Type 1:Sym #:Mode OK:Run")
|
||||
fi
|
||||
end sub
|
||||
|
||||
sub render_tools_tab()
|
||||
local tls_lbl$
|
||||
if tls_insecure then
|
||||
tls_lbl$ = "Insecure"
|
||||
else
|
||||
tls_lbl$ = "Strict"
|
||||
fi
|
||||
|
||||
neoui_draw_toggle_row(0, 62, 32, tool_focus = 0, neoui_icon$("lock"), neoui.TEXT_GREEN, "TLS Cert Check", 1 - tls_insecure, tls_lbl$)
|
||||
neoui_draw_list_row(1, 96, 32, tool_focus = 1, neoui_icon$("folder"), neoui.TEXT_BLUE, "Download example.com", dl_status$, "Run")
|
||||
|
||||
neoui_fill_rect(6, 132, 228, 134, neoui_color(neoui.COLOR_BG_ALT_ODD))
|
||||
neoui_draw_rect(6, 132, 228, 134, neoui_color(neoui.COLOR_BORDER))
|
||||
|
||||
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_YELLOW, 10, 135, 15, "URL Encode / Decode FFI:", 220)
|
||||
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_LIGHT, 10, 150, 14, "In : " + sample_raw$, 220)
|
||||
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_MUTED, 10, 164, 14, "Enc: " + sample_enc$, 220)
|
||||
neoui_draw_line(8, 181, 232, 181, neoui_color(neoui.COLOR_DIVIDER))
|
||||
neoui_draw_text(neoui.FONT_SMALL, neoui.TEXT_YELLOW, 10, 184, 15, "System DNS: " + neonet_system_dns$(), 220)
|
||||
neoui_draw_text_wrapped(neoui.FONT_SMALL, neoui.TEXT_MUTED, 10, 200, 220, 62, "Engine: " + neonet_version$(), 0)
|
||||
end sub
|
||||
|
||||
sub render_all()
|
||||
local badge$, mid_lbl$, right_lbl$
|
||||
neoui_begin_frame()
|
||||
|
||||
if (active_tab = 0 and http_focus = 0) or (active_tab = 1 and sock_focus = 1) then
|
||||
badge$ = neoui_input_mode_badge$()
|
||||
else
|
||||
badge$ = "libcurl"
|
||||
fi
|
||||
|
||||
neoui_draw_header(neoui_icon$("globe"), neoui.TEXT_YELLOW, "NeoNet + NeoUI", badge$)
|
||||
neoui_draw_tabs("1:HTTP/S|2:Sockets|3:Tools", active_tab, 34, 24)
|
||||
|
||||
mid_lbl$ = "Select"
|
||||
right_lbl$ = "Quit"
|
||||
|
||||
if active_tab = 0 then
|
||||
render_http_tab()
|
||||
if http_focus = 0 and len(neoui_input_get_text$()) > 0 then
|
||||
right_lbl$ = "Del"
|
||||
fi
|
||||
if http_focus = 0 or http_focus = 2 then
|
||||
mid_lbl$ = "Send"
|
||||
elsif http_focus = 5 then
|
||||
mid_lbl$ = "Hdr/Body"
|
||||
fi
|
||||
elsif active_tab = 1 then
|
||||
render_sockets_tab()
|
||||
if sock_focus = 1 and len(neoui_input_get_text$()) > 0 then
|
||||
right_lbl$ = "Del"
|
||||
fi
|
||||
if sock_focus = 1 or sock_focus = 2 then
|
||||
mid_lbl$ = "Run"
|
||||
fi
|
||||
else
|
||||
render_tools_tab()
|
||||
fi
|
||||
|
||||
if modal_mode = 1 then
|
||||
neoui_draw_menu_popup("HTTPS GET example.com|HTTPS HEAD example.com|TLS :443 Raw Exchange|TCP :43 WHOIS Lookup|UDP :53 DNS Resolve|Reload Theme|Quit Demo", neoui_icon$("globe") + "|" + neoui_icon$("info") + "|" + neoui_icon$("lock") + "|" + neoui_icon$("term") + "|" + neoui_icon$("wifi") + "|" + neoui_icon$("theme") + "|" + neoui_icon$("close"), menu_sel, 7)
|
||||
neoui_draw_softkeys("Close", "Run", "Back")
|
||||
else
|
||||
neoui_draw_softkeys("Presets", mid_lbl$, right_lbl$)
|
||||
fi
|
||||
|
||||
neoui_end_frame()
|
||||
end sub
|
||||
|
||||
render_all()
|
||||
|
||||
running = 1
|
||||
while running
|
||||
ev = neoui_poll_event(250)
|
||||
|
||||
if ev = neoui.EV_CLOSE_REQ then
|
||||
running = 0
|
||||
elsif ev = neoui.EV_EXPOSE or ev = neoui.EV_THEME_RELOAD then
|
||||
render_all()
|
||||
elsif ev = neoui.EV_SOFTKEY_LEFT then
|
||||
save_input_box()
|
||||
if modal_mode = 0 then
|
||||
modal_mode = 1
|
||||
menu_sel = 0
|
||||
else
|
||||
modal_mode = 0
|
||||
fi
|
||||
render_all()
|
||||
elsif ev = neoui.EV_SOFTKEY_RIGHT then
|
||||
if modal_mode <> 0 then
|
||||
modal_mode = 0
|
||||
render_all()
|
||||
elsif active_tab = 0 and http_focus = 0 and len(neoui_input_get_text$()) > 0 then
|
||||
neoui_input_backspace()
|
||||
http_url$ = neoui_input_get_text$()
|
||||
render_all()
|
||||
elsif active_tab = 1 and sock_focus = 1 and len(neoui_input_get_text$()) > 0 then
|
||||
neoui_input_backspace()
|
||||
sock_host$ = neoui_input_get_text$()
|
||||
render_all()
|
||||
else
|
||||
running = 0
|
||||
fi
|
||||
elsif ev = neoui.EV_KEY_PRESS then
|
||||
k = neoui_event_key()
|
||||
|
||||
if modal_mode = 1 then
|
||||
if k = neoui.KEY_UP then
|
||||
menu_sel = mod(menu_sel + 6, 7)
|
||||
elsif k = neoui.KEY_DOWN then
|
||||
menu_sel = mod(menu_sel + 1, 7)
|
||||
elsif k = neoui.KEY_BACK then
|
||||
modal_mode = 0
|
||||
elsif k = neoui.KEY_OK then
|
||||
modal_mode = 0
|
||||
if menu_sel = 0 then
|
||||
active_tab = 0
|
||||
http_focus = 2
|
||||
http_url$ = "https://example.com/"
|
||||
http_method_idx = 0
|
||||
show_raw_headers = 0
|
||||
run_http_request()
|
||||
elsif menu_sel = 1 then
|
||||
active_tab = 0
|
||||
http_focus = 2
|
||||
http_url$ = "https://example.com/"
|
||||
http_method_idx = 2
|
||||
show_raw_headers = 1
|
||||
run_http_request()
|
||||
elsif menu_sel = 2 then
|
||||
active_tab = 1
|
||||
sock_focus = 2
|
||||
sock_proto_idx = 0
|
||||
sock_host$ = "example.com"
|
||||
run_socket_exchange()
|
||||
elsif menu_sel = 3 then
|
||||
active_tab = 1
|
||||
sock_focus = 2
|
||||
sock_proto_idx = 1
|
||||
sock_host$ = "example.com"
|
||||
run_socket_exchange()
|
||||
elsif menu_sel = 4 then
|
||||
active_tab = 1
|
||||
sock_focus = 2
|
||||
sock_proto_idx = 2
|
||||
sock_host$ = "example.com"
|
||||
run_socket_exchange()
|
||||
elsif menu_sel = 5 then
|
||||
neoui_reload_theme()
|
||||
neoui_show_toast("Theme reloaded!", 1400)
|
||||
elsif menu_sel = 6 then
|
||||
running = 0
|
||||
fi
|
||||
fi
|
||||
render_all()
|
||||
|
||||
elsif active_tab = 0 and http_focus = 0 then
|
||||
sync_input_box(0)
|
||||
if k = neoui.KEY_UP then
|
||||
save_input_box()
|
||||
http_focus = 5
|
||||
elsif k = neoui.KEY_DOWN then
|
||||
save_input_box()
|
||||
http_focus = 1
|
||||
elsif k = neoui.KEY_OK then
|
||||
run_http_request()
|
||||
else
|
||||
neoui_input_feed_key(k)
|
||||
http_url$ = neoui_input_get_text$()
|
||||
fi
|
||||
render_all()
|
||||
|
||||
elsif active_tab = 1 and sock_focus = 1 then
|
||||
sync_input_box(1)
|
||||
if k = neoui.KEY_UP then
|
||||
save_input_box()
|
||||
sock_focus = 0
|
||||
elsif k = neoui.KEY_DOWN then
|
||||
save_input_box()
|
||||
sock_focus = 2
|
||||
elsif k = neoui.KEY_OK then
|
||||
run_socket_exchange()
|
||||
else
|
||||
neoui_input_feed_key(k)
|
||||
sock_host$ = neoui_input_get_text$()
|
||||
fi
|
||||
render_all()
|
||||
|
||||
else
|
||||
if k = neoui.KEY_1 then
|
||||
save_input_box()
|
||||
active_tab = 0
|
||||
elsif k = neoui.KEY_2 then
|
||||
save_input_box()
|
||||
active_tab = 1
|
||||
elsif k = neoui.KEY_3 then
|
||||
save_input_box()
|
||||
active_tab = 2
|
||||
elsif k = neoui.KEY_BACK then
|
||||
running = 0
|
||||
elsif active_tab = 0 then
|
||||
if k = neoui.KEY_UP then
|
||||
if http_focus = 5 and http_scroll > 0 then
|
||||
http_scroll = http_scroll - 1
|
||||
else
|
||||
http_focus = mod(http_focus + 5, 6)
|
||||
fi
|
||||
elsif k = neoui.KEY_DOWN then
|
||||
if http_focus = 5 then
|
||||
http_scroll = http_scroll + 1
|
||||
else
|
||||
http_focus = mod(http_focus + 1, 6)
|
||||
fi
|
||||
elsif k = neoui.KEY_LEFT then
|
||||
if http_focus = 3 then
|
||||
http_method_idx = mod(http_method_idx + 2, 3)
|
||||
elsif http_focus = 4 then
|
||||
http_focus = 3
|
||||
elsif http_focus = 5 and http_scroll > 0 then
|
||||
http_scroll = 0
|
||||
http_focus = 2
|
||||
else
|
||||
active_tab = 2
|
||||
fi
|
||||
elsif k = neoui.KEY_RIGHT then
|
||||
if http_focus = 2 then
|
||||
http_focus = 3
|
||||
elsif http_focus = 3 then
|
||||
http_focus = 4
|
||||
else
|
||||
active_tab = 1
|
||||
fi
|
||||
elsif k = neoui.KEY_OK then
|
||||
if http_focus = 1 then
|
||||
custom_hdr_on = 1 - custom_hdr_on
|
||||
elsif http_focus = 2 then
|
||||
run_http_request()
|
||||
elsif http_focus = 3 then
|
||||
http_method_idx = mod(http_method_idx + 1, 3)
|
||||
elsif http_focus = 4 or http_focus = 5 then
|
||||
show_raw_headers = 1 - show_raw_headers
|
||||
http_scroll = 0
|
||||
if show_raw_headers then
|
||||
http_output$ = sanitize_display_text$(neonet_response_headers$(), 1800)
|
||||
else
|
||||
http_output$ = sanitize_display_text$(neonet_body$(), 1800)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
elsif active_tab = 1 then
|
||||
if k = neoui.KEY_UP then
|
||||
if sock_focus = 4 and sock_scroll > 0 then
|
||||
sock_scroll = sock_scroll - 1
|
||||
else
|
||||
sock_focus = mod(sock_focus + 4, 5)
|
||||
fi
|
||||
elsif k = neoui.KEY_DOWN then
|
||||
if sock_focus = 4 then
|
||||
sock_scroll = sock_scroll + 1
|
||||
else
|
||||
sock_focus = mod(sock_focus + 1, 5)
|
||||
fi
|
||||
elsif k = neoui.KEY_LEFT then
|
||||
if sock_focus = 0 then
|
||||
sock_proto_idx = mod(sock_proto_idx + 2, 3)
|
||||
elsif sock_focus = 3 then
|
||||
sock_focus = 2
|
||||
else
|
||||
active_tab = 0
|
||||
fi
|
||||
elsif k = neoui.KEY_RIGHT then
|
||||
if sock_focus = 0 then
|
||||
sock_proto_idx = mod(sock_proto_idx + 1, 3)
|
||||
elsif sock_focus = 2 then
|
||||
sock_focus = 3
|
||||
else
|
||||
active_tab = 2
|
||||
fi
|
||||
elsif k = neoui.KEY_OK then
|
||||
if sock_focus = 0 then
|
||||
sock_proto_idx = mod(sock_proto_idx + 1, 3)
|
||||
elsif sock_focus = 2 then
|
||||
run_socket_exchange()
|
||||
elsif sock_focus = 3 then
|
||||
sock_output$ = ""
|
||||
sock_status_str$ = "Cleared"
|
||||
sock_scroll = 0
|
||||
fi
|
||||
fi
|
||||
elsif active_tab = 2 then
|
||||
if k = neoui.KEY_UP or k = neoui.KEY_DOWN then
|
||||
tool_focus = 1 - tool_focus
|
||||
elsif k = neoui.KEY_LEFT then
|
||||
active_tab = 1
|
||||
elsif k = neoui.KEY_RIGHT then
|
||||
active_tab = 0
|
||||
elsif k = neoui.KEY_OK then
|
||||
if tool_focus = 0 then
|
||||
tls_insecure = 1 - tls_insecure
|
||||
r = neonet_set_insecure(tls_insecure)
|
||||
if tls_insecure then
|
||||
neoui_show_toast("TLS cert check disabled", 1400)
|
||||
else
|
||||
neoui_show_toast("TLS cert check enabled", 1400)
|
||||
fi
|
||||
elsif tool_focus = 1 then
|
||||
neoui_show_toast("Downloading to /tmp/neonet_dl.html ...", 500)
|
||||
render_all()
|
||||
neoui_flush()
|
||||
if neonet_download("https://example.com/", "/tmp/neonet_dl.html", "") then
|
||||
dl_status$ = "Saved /tmp/neonet_dl.html (HTTP " + str$(neonet_status()) + ")"
|
||||
neoui_show_toast("Saved /tmp/neonet_dl.html!", 1600)
|
||||
else
|
||||
dl_status$ = "Error: " + neonet_error$()
|
||||
neoui_show_toast("Download failed", 1600)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
render_all()
|
||||
fi
|
||||
fi
|
||||
wend
|
||||
|
||||
r = neonet_cleanup()
|
||||
neoui_shutdown()
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
export HOME="${HOME:-/home/user}"
|
||||
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/10000}"
|
||||
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
||||
export DISPLAY="${DISPLAY:-:0}"
|
||||
export LANG=C.UTF-8
|
||||
export LC_ALL=C.UTF-8
|
||||
export CHARSET=UTF-8
|
||||
export XMODIFIERS=@im=fcitx
|
||||
export GTK_IM_MODULE=fcitx
|
||||
export QT_IM_MODULE=fcitx
|
||||
|
||||
if [ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ] && [ -r "$XDG_RUNTIME_DIR/dbus.bus" ]; then
|
||||
read -r DBUS_SESSION_BUS_ADDRESS < "$XDG_RUNTIME_DIR/dbus.bus" 2>/dev/null || true
|
||||
export DBUS_SESSION_BUS_ADDRESS
|
||||
fi
|
||||
|
||||
if [ -d /home/user/.local/x11 ]; then
|
||||
export FCITX_ADDON_DIRS=/home/user/.local/lib/fcitx5:/home/user/.local/x11:/usr/lib/fcitx5
|
||||
else
|
||||
export FCITX_ADDON_DIRS=/home/user/.local/lib/fcitx5:/usr/lib/fcitx5
|
||||
fi
|
||||
|
||||
for p in $(pidof fcitx5 2>/dev/null || true); do
|
||||
if [ "$p" != "$$" ] && [ "$p" != "$PPID" ]; then
|
||||
kill "$p" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
sleep 0.05
|
||||
for p in $(pidof fcitx5 2>/dev/null || true); do
|
||||
if [ "$p" != "$$" ] && [ "$p" != "$PPID" ]; then
|
||||
kill -9 "$p" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
|
||||
exec /usr/bin/fcitx5 -D --disable=wayland >/tmp/fcitx5.log 2>&1
|
||||
@@ -93,7 +93,6 @@ trap 'rm -f "$SESSION_PID_FILE"; pkill -P $$ >/dev/null 2>&1 || true; exit 0' IN
|
||||
pkill -9 -x conky >/dev/null 2>&1 || true
|
||||
rm -rf /tmp/sxmo_conky_time_state /tmp/sxmo_conky_restart.lock
|
||||
DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true
|
||||
pidof -s fcitx5 >/dev/null 2>&1 || fcitx5 -d >/tmp/fcitx5.log 2>&1 </dev/null &
|
||||
sxmo_hook_start.sh >/tmp/sxmo_hook_start.log 2>&1 </dev/null &
|
||||
|
||||
first_iter=1
|
||||
@@ -125,7 +124,7 @@ while [ "$(cat "$SESSION_PID_FILE" 2>/dev/null)" = "$$" ]; do
|
||||
pkill -9 -x conky >/dev/null 2>&1 || true
|
||||
rm -rf /tmp/sxmo_conky_time_state /tmp/sxmo_conky_restart.lock
|
||||
DISPLAY=:0 CONKY_DPY=:0 conky -c /home/user/.config/sxmo/conky.conf -d >/dev/null 2>&1 </dev/null || true
|
||||
pidof -s fcitx5 >/dev/null 2>&1 || fcitx5 -d >/tmp/fcitx5.log 2>&1 </dev/null &
|
||||
pidof -s fcitx5 >/dev/null 2>&1 || superctl start fcitx5 >/dev/null 2>&1 || /usr/bin/bananarchy-fcitx5.sh </dev/null &
|
||||
fi
|
||||
first_iter=0
|
||||
dwm >/tmp/dwm.log 2>&1 || true
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable
+78
@@ -0,0 +1,78 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
# This script is meant to be sourced by various sxmo scripts
|
||||
# and defines some common settings
|
||||
|
||||
export HOME="${HOME:-/home/user}"
|
||||
export DISPLAY="${DISPLAY:-:0}"
|
||||
export SXMO_WM="${SXMO_WM:-dwm}"
|
||||
export SXMO_MENU="${SXMO_MENU:-dmenu}"
|
||||
export SXMO_TERMINAL="${SXMO_TERMINAL:-st}"
|
||||
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/10000}"
|
||||
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
||||
export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
|
||||
export LANG="${LANG:-C.UTF-8}"
|
||||
export LC_ALL="${LC_ALL:-C.UTF-8}"
|
||||
export XMODIFIERS="${XMODIFIERS:-@im=fcitx}"
|
||||
export GTK_IM_MODULE="${GTK_IM_MODULE:-fcitx}"
|
||||
export QT_IM_MODULE="${QT_IM_MODULE:-fcitx}"
|
||||
|
||||
if [ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ] && [ -r "$XDG_RUNTIME_DIR/dbus.bus" ]; then
|
||||
read -r DBUS_SESSION_BUS_ADDRESS < "$XDG_RUNTIME_DIR/dbus.bus" 2>/dev/null || true
|
||||
export DBUS_SESSION_BUS_ADDRESS
|
||||
fi
|
||||
|
||||
# aliases aren't expanded in bash
|
||||
# shellcheck disable=SC2039,SC3044
|
||||
command -v shopt > /dev/null && shopt -s expand_aliases
|
||||
|
||||
alias dmenu="sxmo_dmenu.sh"
|
||||
alias bemenu="sxmo_dmenu.sh"
|
||||
|
||||
if ! command -v sxmobar > /dev/null; then
|
||||
sxmobar() {
|
||||
sxmo_status.sh "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
confirm_menu() {
|
||||
printf "No\nYes\n" | \
|
||||
dmenu "$@" | \
|
||||
grep -q "Yes"
|
||||
}
|
||||
|
||||
sxmo_log() {
|
||||
printf "%s %s: %s\n" "$(date +%H:%M:%S)" "${0##*/}" "$*" | tee -a "${XDG_STATE_HOME:-$HOME}"/sxmo.log 1>&2
|
||||
}
|
||||
|
||||
sxmo_debug() {
|
||||
if [ -n "$SXMO_DEBUG" ]; then
|
||||
printf "%s %s DEBUG: %s\n" "$(date +%H:%M:%S)" "${0##*/}" "$*" | tee -a "${XDG_STATE_HOME:-$HOME}"/sxmo.log 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
xdg_data_path() {
|
||||
filepath=$1
|
||||
instance_count=${2:-1}
|
||||
sep=${3:-" "}
|
||||
|
||||
IFS=':'
|
||||
instance=0
|
||||
for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
|
||||
do
|
||||
if [ -e "$dir/$filepath" ]; then
|
||||
if [ "$instance" -ge "$instance_count" ] && [ "$instance_count" != "0" ]; then
|
||||
break
|
||||
fi
|
||||
if [ $instance -gt 0 ]; then
|
||||
printf '%b' "${sep}"
|
||||
fi
|
||||
printf '%s' "${dir}/${filepath}"
|
||||
instance=$((instance+1))
|
||||
fi
|
||||
done
|
||||
}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/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
|
||||
|
||||
if [ -e /tmp/dwm_plugin_dmenu.active ] && [ -p /tmp/dwm_plugin_dmenu.fifo ]; then
|
||||
printf "CLOSE\n" > /tmp/dwm_plugin_dmenu.fifo 2>/dev/null || true
|
||||
sleep 0.04
|
||||
fi
|
||||
|
||||
for _pair in \
|
||||
"xdrawer.pid:/tmp/dwm_plugin_xdrawer.fifo" \
|
||||
"xdialer.pid:/tmp/dwm_plugin_dialer.fifo" \
|
||||
"xcalllog.pid:/tmp/dwm_plugin_calllog.fifo" \
|
||||
"xcontacts.pid:/tmp/dwm_plugin_contacts.fifo" \
|
||||
"xsms.pid:/tmp/dwm_plugin_sms.fifo" \
|
||||
"xfiles.pid:/tmp/dwm_plugin_files.fifo" \
|
||||
"xcamera.pid:/tmp/dwm_plugin_camera.fifo" \
|
||||
"xthemes.pid:/tmp/dwm_plugin_themes.fifo" \
|
||||
"xmodem.pid:/tmp/dwm_plugin_modem.fifo" \
|
||||
"xnetworks.pid:/tmp/dwm_plugin_networks.fifo" \
|
||||
"xringtones.pid:/tmp/dwm_plugin_ringtones.fifo" \
|
||||
"xwallpapers.pid:/tmp/dwm_plugin_wallpapers.fifo" \
|
||||
"xmusic.pid:/tmp/dwm_plugin_music.fifo"; do
|
||||
_pf="${_pair%%:*}"
|
||||
_ff="${_pair#*:}"
|
||||
if [ -f "${XDG_RUNTIME_DIR:-/run/user/10000}/$_pf" ] || [ -f "/tmp/$_pf" ]; then
|
||||
if [ -p "$_ff" ]; then
|
||||
printf "CLOSE\n" > "$_ff" 2>/dev/null || true
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
case "${SXMO_WM:-dwm}" in
|
||||
i3) i3-msg kill ;;
|
||||
sway) swaymsg kill ;;
|
||||
river) riverctl close ;;
|
||||
dwm|*)
|
||||
_wid="$(xdotool getactivewindow 2>/dev/null || true)"
|
||||
xdotool key --clearmodifiers Super+Shift+c 2>/dev/null || true
|
||||
if [ -n "$_wid" ]; then
|
||||
sleep 0.1
|
||||
if xprop -id "$_wid" WM_STATE >/dev/null 2>&1; then
|
||||
xdotool windowkill "$_wid" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -7,6 +7,19 @@
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
|
||||
export DISPLAY="${DISPLAY:-:0}"
|
||||
export SXMO_WM="${SXMO_WM:-dwm}"
|
||||
|
||||
_dwm_prep() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
if [ -e /tmp/dwm_plugin_dmenu.active ] && [ -p /tmp/dwm_plugin_dmenu.fifo ]; then
|
||||
printf "CLOSE\n" > /tmp/dwm_plugin_dmenu.fifo 2>/dev/null || true
|
||||
sleep 0.04
|
||||
fi
|
||||
}
|
||||
|
||||
swi3msg() {
|
||||
case "$SXMO_WM" in
|
||||
sway) swaymsg "$@" ;;
|
||||
@@ -328,10 +341,8 @@ swi3togglelayout() {
|
||||
}
|
||||
|
||||
dwmtogglelayout() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
xdotool key --clearmodifiers key Super+space
|
||||
_dwm_prep
|
||||
xdotool key --clearmodifiers Super+space
|
||||
}
|
||||
|
||||
rivertogglelayout() {
|
||||
@@ -349,9 +360,7 @@ swayswitchfocus() {
|
||||
}
|
||||
|
||||
dwmswitchfocus() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
_dwm_prep
|
||||
xdotool key --clearmodifiers Super+x
|
||||
}
|
||||
# }}}
|
||||
@@ -392,9 +401,7 @@ rivernextworkspace() {
|
||||
}
|
||||
|
||||
dwmnextworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
_dwm_prep
|
||||
xdotool key --clearmodifiers Super+Shift+r
|
||||
}
|
||||
|
||||
@@ -403,9 +410,7 @@ swi3previousworkspace() {
|
||||
}
|
||||
|
||||
dwmpreviousworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
_dwm_prep
|
||||
xdotool key --clearmodifiers Super+Shift+e
|
||||
}
|
||||
|
||||
@@ -418,9 +423,7 @@ swi3movenextworkspace() {
|
||||
}
|
||||
|
||||
dwmmovenextworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
_dwm_prep
|
||||
xdotool key --clearmodifiers Super+r
|
||||
}
|
||||
|
||||
@@ -429,9 +432,7 @@ swi3movepreviousworkspace() {
|
||||
}
|
||||
|
||||
dwmmovepreviousworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
_dwm_prep
|
||||
xdotool key --clearmodifiers Super+e
|
||||
}
|
||||
|
||||
@@ -445,9 +446,7 @@ riverworkspace() {
|
||||
}
|
||||
|
||||
dwmworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
_dwm_prep
|
||||
xdotool key --clearmodifiers "Super+$1"
|
||||
}
|
||||
|
||||
@@ -461,9 +460,7 @@ rivermoveworkspace() {
|
||||
}
|
||||
|
||||
dwmmoveworkspace() {
|
||||
if [ -z "$DISPLAY" ]; then
|
||||
export DISPLAY=:0
|
||||
fi
|
||||
_dwm_prep
|
||||
xdotool key --clearmodifiers "Super+shift+$1"
|
||||
}
|
||||
# }}}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
/home/user/Projects/neonet.yab
|
||||
@@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=fcitx5 input support
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/bananarchy-fcitx5.sh
|
||||
Restart=always
|
||||
@@ -78,7 +78,7 @@ superctl start dunst
|
||||
[ "$(command -v sxmo_xob)" ] && superctl start sxmo_xob
|
||||
pidof -s sxmo_status_xsetroot.sh >/dev/null 2>&1 || superctl start sxmo-x11-status
|
||||
[ "$(command -v bonsaid)" ] && superctl start bonsaid
|
||||
if ! pidof -s fcitx5 >/dev/null 2>&1 && [ "$(command -v fcitx5)" ]; then
|
||||
if [ "$(command -v fcitx5)" ]; then
|
||||
superctl start fcitx5
|
||||
fi
|
||||
[ -n "$SXMO_MONITOR" ] && xrandr --output "$SXMO_MONITOR" --primary
|
||||
|
||||
Reference in new issue
Block a user