Konrad, 2026-11-13: "panel fehlt, top leiste is lila", the network settings "zu rudimentaer, keine ip config, kein dns", the global menu only while a program that has one is in front. The bar (and the launcher, the drop-down terminal, the login items) came from Xsession.d, before dtsession had loaded the session's resources and the colour server: dtbar took *background from ~/.Xdefaults (#6e1e7d, the user's base16 theme; dtbar PID 1270788 started before dtsession 1270795). Restarting dtbar in the running session gave the palette's colours. Now dtsession runs sys.sessionetc -- the first of CDE_CONFIGURATION_TOP/config and CDE_INSTALLATION_TOP/config, as sys.session is found -- before the user's sessionetc (SmRestore.c, StartEtc); it sources config/sessionetc.d, where 0080.dtlaunch, 0085.dtdropdown, 0090.dtbar and 0095.loginitems moved. The bar takes colour set 5, the programs' background, not set 6 of a menu bar (Dtbar*secondaryColorSetId: 5; measured #c6b2a8 with Default.dp). dtwm publishes the focused client as _NET_ACTIVE_WINDOW (EWMH, WmEwmh.c SetNetActiveWindow from SetKeyboardFocus and where the focus is dropped); dtbar shows a program's menus only while the active window is the menus' owner, a dialog of it (WM_TRANSIENT_FOR) or a window of the same program (WM_CLIENT_LEADER). Measured on Xvfb with dtwm, dtbar, dtpad and xterm, clicking: dtpad -> its menus, xterm -> M only, dtpad -> its menus again. Network (dtsystemsettings/network.c, docs/reference/netconfig.txt): Show: Network Status (a light and a sentence per card, Configure...) or one card with the tabs TCP/IP (Using DHCP, with manual address, Manually, Off; address, mask, router, DHCP client ID, Renew DHCP Lease; IPv6), DNS (servers, search domains, what resolv.conf has now), Wi-Fi and Ethernet; the lock and Apply Now as Accounts. McdeSys mcde_sys_net_config, _configure, _renew (replacing mcde_sys_net_dhcp, which was declared and implemented nowhere): NetBSD one block per interface in dhcpcd.conf, as ifconfig.if(5) recommends, sysinst's static address in ifconfig.IF read and moved there, applied with dhcpcd -n IF (cross-compiled with the tree's x86_64--netbsd-gcc, not run); Linux the NetworkManager profile (nmcli). mcde_sys_interfaces took the last IPv4 address (the secondary one), now the first. Measured on this host, read only: the pane shows the three cards, 172.20.10.2/28 by DHCP, router 172.20.10.1, DNS 1.1.1.1, MAC, MTU 1500; test_sysinfo (new checks: settings read, 300.1.2.3 refused) exit 0. Nothing was applied on the development host. From the review of 2026-11-12's commits: libDtTerm links libMcdeSound (977a7347c made the bell call McdeSoundEvent; dtcodegen did not link); the PLIST lacked dtphoto, dtpaint, dttoolbox, mcdesoundd, libMcdeSound, their data and the sound themes (51 entries, from the installed tree); mcdesoundd was started by nothing (sessionetc.d/0075.mcdesoundd) and took the selection from a running server; dttoolbox kept only the first line of the Selected menu and rebuilt it every 500 ms, and NewMenu returned an uninitialised pointer past 64 menus. Built and installed with make mcde-host MCDE_DIRS=install, exit 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
290 lines
7.8 KiB
C
290 lines
7.8 KiB
C
/*
|
|
* startup.c -- dtsystemsettings: what happens when you log in and out
|
|
*
|
|
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
|
|
*
|
|
* The session: at login the session left or the home session, whether
|
|
* logging out asks first, and "Save as Home Session" -- what CDE's style
|
|
* manager sets (programs/dtstyle/Startup.c), sent the same way
|
|
* (programs/dtstyle/Protocol.c: _DtSetSmState with SM_STATE_START and
|
|
* SM_STATE_CONFIRM; the client message _DT_SM_SAVE_TO_HOME of the protocol
|
|
* _DT_SM_STM_PROTOCOL).
|
|
*
|
|
* The programs opened at login: one command a line in ~/.dt/login-items,
|
|
* started by sessionetc.d/0095.loginitems (programs/dtlogin/config) as
|
|
* sys.sessionetc starts the bar. A line can be added or taken out here.
|
|
*
|
|
* C99, POSIX, Xt and Motif only (ext/src/mcde/AGENTS.md).
|
|
*/
|
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/stat.h>
|
|
|
|
#include <X11/Intrinsic.h>
|
|
#include <Xm/Xm.h>
|
|
#include <Xm/List.h>
|
|
#include <Xm/RowColumn.h>
|
|
#include <Xm/Separator.h>
|
|
#include <Xm/TextF.h>
|
|
#include <Xm/ToggleB.h>
|
|
#include <Dt/SessionM.h>
|
|
|
|
#include "ui.h"
|
|
|
|
#define MAX_ITEMS 64
|
|
|
|
static Widget resumeToggle, homeToggle, confirmToggle, startupNote;
|
|
static Widget itemList, itemField;
|
|
static char *items[MAX_ITEMS];
|
|
static int nitems;
|
|
static Window sm;
|
|
|
|
/* ---- the session -------------------------------------------------------- */
|
|
|
|
static void
|
|
SendState(void)
|
|
{
|
|
Display *dpy = XtDisplay(resumeToggle);
|
|
SmStateInfo state;
|
|
|
|
if (sm == None)
|
|
return;
|
|
memset(&state, 0, sizeof state);
|
|
state.flags = SM_STATE_START | SM_STATE_CONFIRM;
|
|
state.smStartState = XmToggleButtonGetState(homeToggle) ?
|
|
DtSM_HOME_STATE : DtSM_CURRENT_STATE;
|
|
state.smConfirmMode = XmToggleButtonGetState(confirmToggle) ?
|
|
DtSM_VERBOSE_MODE : DtSM_QUIET_MODE;
|
|
_DtSetSmState(dpy, sm, &state);
|
|
XFlush(dpy);
|
|
}
|
|
|
|
static void
|
|
StateChanged(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
(void) data;
|
|
/* the radio pair: only the one switched on counts */
|
|
if (w != confirmToggle &&
|
|
!((XmToggleButtonCallbackStruct *) call)->set)
|
|
return;
|
|
SendState();
|
|
}
|
|
|
|
static void
|
|
SaveHome(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
Display *dpy = XtDisplay(w);
|
|
XClientMessageEvent ev;
|
|
|
|
(void) data;
|
|
(void) call;
|
|
if (sm == None)
|
|
return;
|
|
/* dtstyle's SmSaveHomeSession */
|
|
memset(&ev, 0, sizeof ev);
|
|
ev.type = ClientMessage;
|
|
ev.window = sm;
|
|
ev.message_type = XInternAtom(dpy, _XA_DT_SM_STM_PROTOCOL, False);
|
|
ev.format = 32;
|
|
ev.data.l[0] = (long) XInternAtom(dpy, _XA_DT_SM_SAVE_TO_HOME, False);
|
|
ev.data.l[1] = XmToggleButtonGetState(homeToggle) ? DtSM_HOME_STATE :
|
|
DtSM_CURRENT_STATE;
|
|
ev.data.l[2] = XmToggleButtonGetState(confirmToggle) ?
|
|
DtSM_VERBOSE_MODE : DtSM_QUIET_MODE;
|
|
ev.data.l[3] = CurrentTime;
|
|
XSendEvent(dpy, sm, False, NoEventMask, (XEvent *) &ev);
|
|
XFlush(dpy);
|
|
SetText(startupNote, "The windows open now are the home session.");
|
|
}
|
|
|
|
/* ---- the programs opened at login --------------------------------------- */
|
|
|
|
static void
|
|
ItemsFile(char *buf, size_t len)
|
|
{
|
|
const char *home = getenv("HOME");
|
|
|
|
snprintf(buf, len, "%s/.dt/login-items", home != NULL ? home : ".");
|
|
}
|
|
|
|
static void
|
|
ReadItems(void)
|
|
{
|
|
char path[1100], line[1024];
|
|
FILE *fp;
|
|
|
|
nitems = 0;
|
|
ItemsFile(path, sizeof path);
|
|
if ((fp = fopen(path, "r")) == NULL)
|
|
return;
|
|
while (nitems < MAX_ITEMS && fgets(line, sizeof line, fp) != NULL) {
|
|
line[strcspn(line, "\r\n")] = '\0';
|
|
if (line[0] == '\0' || line[0] == '#')
|
|
continue;
|
|
items[nitems++] = strdup(line);
|
|
}
|
|
fclose(fp);
|
|
}
|
|
|
|
static int
|
|
WriteItems(void)
|
|
{
|
|
char path[1100], tmp[1200];
|
|
FILE *fp;
|
|
int i;
|
|
|
|
ItemsFile(path, sizeof path);
|
|
snprintf(tmp, sizeof tmp, "%s.new", path);
|
|
if ((fp = fopen(tmp, "w")) == NULL)
|
|
return 0;
|
|
fprintf(fp, "# the programs opened at login, one command a line\n"
|
|
"# (MCDE System Settings, Startup; started by sessionetc.d/"
|
|
"0095.loginitems)\n");
|
|
for (i = 0; i < nitems; i++)
|
|
fprintf(fp, "%s\n", items[i]);
|
|
if (fclose(fp) != 0 || rename(tmp, path) != 0) {
|
|
remove(tmp);
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static void
|
|
FillItems(void)
|
|
{
|
|
int i;
|
|
|
|
XmListDeleteAllItems(itemList);
|
|
for (i = 0; i < nitems; i++) {
|
|
XmString s = XmStringCreateLocalized(items[i]);
|
|
|
|
XmListAddItemUnselected(itemList, s, 0);
|
|
XmStringFree(s);
|
|
}
|
|
}
|
|
|
|
static void
|
|
AddItem(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
char *cmd = XmTextFieldGetString(itemField);
|
|
|
|
(void) data;
|
|
(void) call;
|
|
if (cmd != NULL && cmd[strspn(cmd, " \t")] != '\0' &&
|
|
strchr(cmd, '\n') == NULL && nitems < MAX_ITEMS) {
|
|
items[nitems++] = strdup(cmd);
|
|
if (WriteItems()) {
|
|
FillItems();
|
|
XmTextFieldSetString(itemField, "");
|
|
} else {
|
|
free(items[--nitems]);
|
|
Message(w, "The list could not be written to "
|
|
"~/.dt/login-items.", 1);
|
|
}
|
|
}
|
|
XtFree(cmd);
|
|
}
|
|
|
|
static void
|
|
RemoveItem(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
int *pos = NULL, n = 0, i;
|
|
|
|
(void) data;
|
|
(void) call;
|
|
if (!XmListGetSelectedPos(itemList, &pos, &n) || n < 1 ||
|
|
pos[0] < 1 || pos[0] > nitems) {
|
|
XtFree((char *) pos);
|
|
return;
|
|
}
|
|
i = pos[0] - 1;
|
|
XtFree((char *) pos);
|
|
free(items[i]);
|
|
memmove(items + i, items + i + 1,
|
|
(size_t) (nitems - i - 1) * sizeof items[0]);
|
|
nitems--;
|
|
if (!WriteItems())
|
|
Message(w, "The list could not be written to ~/.dt/login-items.",
|
|
1);
|
|
FillItems();
|
|
}
|
|
|
|
static void
|
|
StartupGone(Widget w, XtPointer data, XtPointer call)
|
|
{
|
|
int i;
|
|
|
|
(void) w;
|
|
(void) data;
|
|
(void) call;
|
|
for (i = 0; i < nitems; i++)
|
|
free(items[i]);
|
|
nitems = 0;
|
|
}
|
|
|
|
Widget
|
|
MakeStartup(Widget parent)
|
|
{
|
|
Display *dpy = XtDisplay(parent);
|
|
Widget box = XtVaCreateWidget("startup", xmRowColumnWidgetClass, parent,
|
|
XmNspacing, 6, NULL);
|
|
Widget radio, row;
|
|
SmStateInfo state;
|
|
Arg a[4];
|
|
int home = 0, confirm = 1;
|
|
|
|
memset(&state, 0, sizeof state);
|
|
if (_DtGetSmWindow(dpy, RootWindow(dpy, 0), &sm) != Success)
|
|
sm = None;
|
|
else if (_DtGetSmState(dpy, sm, &state) == Success) {
|
|
home = state.smStartState == DtSM_HOME_STATE;
|
|
confirm = state.smConfirmMode != DtSM_QUIET_MODE;
|
|
}
|
|
|
|
(void) Text(box, "label", "When you log in:");
|
|
radio = XtVaCreateManagedWidget("start", xmRowColumnWidgetClass, box,
|
|
XmNradioBehavior, True, NULL);
|
|
resumeToggle = XtVaCreateManagedWidget(
|
|
"Resume the session you left", xmToggleButtonWidgetClass, radio,
|
|
XmNset, !home, NULL);
|
|
homeToggle = XtVaCreateManagedWidget("Start your home session",
|
|
xmToggleButtonWidgetClass, radio, XmNset, home, NULL);
|
|
XtAddCallback(resumeToggle, XmNvalueChangedCallback, StateChanged, NULL);
|
|
XtAddCallback(homeToggle, XmNvalueChangedCallback, StateChanged, NULL);
|
|
confirmToggle = XtVaCreateManagedWidget("Ask before logging out",
|
|
xmToggleButtonWidgetClass, box, XmNset, confirm, NULL);
|
|
XtAddCallback(confirmToggle, XmNvalueChangedCallback, StateChanged,
|
|
NULL);
|
|
(void) PaneButton(box, "Save These Windows as Home Session", SaveHome,
|
|
NULL);
|
|
startupNote = Text(box, "note", sm == None ? "No session manager runs: "
|
|
"the session settings are not kept." : "");
|
|
if (sm == None) {
|
|
XtSetSensitive(XtParent(resumeToggle), False);
|
|
XtSetSensitive(confirmToggle, False);
|
|
}
|
|
|
|
XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, box, NULL);
|
|
(void) Text(box, "label", "Open these programs when you log in:");
|
|
XtSetArg(a[0], XmNvisibleItemCount, 6);
|
|
XtSetArg(a[1], XmNselectionPolicy, XmBROWSE_SELECT);
|
|
XtSetArg(a[2], XmNwidth, 460);
|
|
itemList = XmCreateScrolledList(box, "items", a, 3);
|
|
XtManageChild(itemList);
|
|
row = XtVaCreateManagedWidget("add", xmRowColumnWidgetClass, box,
|
|
XmNorientation, XmHORIZONTAL, XmNmarginWidth, 0, NULL);
|
|
itemField = XtVaCreateManagedWidget("command", xmTextFieldWidgetClass,
|
|
row, XmNcolumns, 34, NULL);
|
|
XtAddCallback(itemField, XmNactivateCallback, AddItem, NULL);
|
|
(void) Button(row, "Add", AddItem, NULL);
|
|
(void) Button(row, "Remove", RemoveItem, NULL);
|
|
XtAddCallback(box, XmNdestroyCallback, StartupGone, NULL);
|
|
ReadItems();
|
|
FillItems();
|
|
return box;
|
|
}
|