Re: [dev] About xorg and mesa
On Tue, 03 Sep 2024 16:54:36 + stefan1 wrote: > I am using an nvidia gpu with the proprietary drivers, on xorg. > I use the proprietary drivers, because I found that the nouveau > drivers don't really work too well. How did the nouveau drivers not work well? I only use the nouveau drivers, and the only people I know who don't, it is because nvidia drivers are installed by default on Ubuntu. Cheers, Sean
Re: [dev] [edit] Introducing edit, a simple text editor
On Tue, 24 Oct 2023 01:26:24 +0200 Arthur Jacquin wrote: > I'm interested in having a look at the code too, in case you want to > share it ;) No problem. See the README.md for a brief history of zedit. It is probably too big to be suckless, even in its greatly reduced state. Most of the cool stuff is gone... mostly because modern OSes don't need it. It used to have a virtual memory system (saving to swap), extended memory on DOS, optimized disk writes... the list goes on. On DOS it had a cool border, the current line was highlighted, and it dealt with CGA monitors. It also started out with a gap page buffer scheme which was the rage at the time. You created a gap in the middle of each page. The idea was that inserts could use that gap. However, profiling showed that a lot of cpu was being consumed to deal with the gap. Most developers spend a LOT more time reading the code than writing. So zedit is now optimized for reading. Your usage of lines, although it takes more memory, is probably a good thing these days. Might be a problem with files in the gigabyte range ;) https://github.com/smaclennan/zedit The buffer code is split out in its own buff directory. Cheers, Sean
Re: [dev] [edit] Introducing edit, a simple text editor
On Sun, 22 Oct 2023 11:12:09 +0200 Arthur Jacquin wrote: > Undo-ing is clearly a non-trivial feature. I wrote my own editor (zedit or z) in the late '80s. At that time none of the editors I was using had undo... so I didn't add it. It wasn't until I switched to emacs a decade later that I had undo. I added undo to z. It works 100% of the time in testing... but only about 80% of the time if doing real heavy editing. Luckily I only use z for light editing now, so the undo is good enough. Basically, I agree that undo is hard. Cheers, Sean P.S. I lost the link to the source code for edit. Could you resend it?
Re: [dev] Use of sdhcp
On Thu, 05 Oct 2023 16:25:25 +0200 Josuah Demangeon wrote: > Which would provide something acting like Ethernet, > but out of a serial cable instead of a cat6 cable. They could be running serial over a cat6 cable. Some of the embedded systems I am using do this. There is no ethernet involved, they are just re-purposing the cable. Cheers, Sean
Re: [dev] Logical abilities of routers
On Mon, 1 May 2023 09:45:22 -0700 Jeremy wrote: > Pretty neat that you don't use NAT. I had a public IP on my laptop > once(ONCE) & the Chinese kept sending garbage to any port that was > open & it made my laptop hot(almost burned my thighs!) What's your > secret to avoid this?? I had a public IP for 18 years. The secret is to not have open ports ;) In the early years it was not a problem... but it slowly got worse and worse. I moved my website to the cloud. I moved my email to the cloud. For ssh I either moved the port (easy) or later added port knocking (harder). I also found used bad guys in iptables. Basically, if you hit my firewall on a bad port, you are put in the bad guys list. This blocks your ip for a couple of minutes. This makes port scans super expensive. Today I have a Bell router in front of my router with no port forwarding. It means I cannot remotely ssh to my systems... but really hasn't been that limiting since I work mainly from home now. So I have a Bell router, connected to my main router (Linux box), which is connected to a wireless router for wireless. Yes, the Bell router has wireless, but it is in the basement and doesn't have a great signal. And I already had the wireless router. Cheers, Sean
Re: [dev] ipaddr - script friendly ifconfig/ip replacement
On Mon, 27 Mar 2023 14:32:39 -0400 fo...@dnmx.org wrote: > Sorry because I don't really care about the project other than "more > suckless = better", but I got a question: why GitHub? > It's literally depending on Microsoft.. we all know how companies > like MS and Google like to change shit all of a sudden. Simple, MS did not own github when I started using it. So... inertia. Cheers, Sean
Re: [dev] ipaddr - script friendly ifconfig/ip replacement
On Sun, 26 Mar 2023 10:54:19 -0700 Jeremy wrote: > One alternative is to just get the address from ifaddrs->ifa_addr. That is what I did. # /tmp/ipaddr 192.168.1.115 (genet0) 192.168.2.2 (genet0) However, I am not sure what to do if you ask for the ip of the interface: # /tmp/ipaddr genet0 192.168.1.115 Might need a mask arg so you can get the ip you want. Printing all of them isn't script friendly, but might be the correct thing to do? Cheers, Sean
[dev] ipaddr - script friendly ifconfig/ip replacement
I started writing ipaddr almost 20 years ago after the umpteenth time trying to parse ifconfig (and later ip) output in scripts. The original version was get only and Linux only. It now supports Linux, QNX, and most BSDs. However, I rarely use BSD these days... so the set functions may not work 100%. I thought there might be somebody in the suckless community that finds it helpful. You need just the ip address of eth0? % ipaddr eth0 192.168.1.173 Nice simple output. All error output goes to stderr, so you can get just the IP or nothing. No awk/sed/cut needed. Also need the bitmask? % ipaddr -b eth0 192.168.1.173/24 Maybe the netmask instead? % ipaddr -im eth0 192.168.1.173 255.255.255.0 It can also be used to setup an interface: % ipaddr eth0 192.168.0.33/24 192.168.0.1 Will set the ip, netmask and default gateway. I could have also specified the netmask the old way: 255.255.255.0. You can see ipaddr.c on github: https://github.com/smaclennan/samtools/blob/master/ipaddr.c I can email the file to anybody who wants it. It is only 6k gzipped. Cheers, Sean
Re: [dev] Is there a text editor following the UNIX philosophy?
On Fri, 11 Feb 2022 11:47:56 + Daniel Littlewood wrote: > I wonder whether there are any text-editing (particularly > code-editing) workflows people have had success with which combine > many small programs, rather than using a single monolith. On development machines there are two places where I want power, and one where I have no choice. 1) My editor. I spend all day in the editor. I want it to be very flexible. I use Emacs. But I don't use it to read mail or browse the web even though it can. 2) My shell. I use zsh. 3) I have to use chrome or firefox as a browser because of work related web based apps. I have no choice here, well no choice if I want to keep my job ;) I can get away with a less powerful shell as long as it has tab completion. Tab completion just saves so much time. Cheers, Sean
Re: [dev] sshd?
On Wed, 7 Jul 2021 08:55:07 +0800 Patrick <201009-suckl...@planhack.com> wrote: > Hi all, > > What's a good minimal sshd? > > Or should we just run stunnel + telnetd? > > > Patrick > > dropbear https://matt.ucc.asn.au/dropbear/dropbear.html Cheers, Sean
[dev] [sdhcp] The problem with renewals
I found a couple of bugs in sdhcp... both having to do with renewal. If you are having problems renewing your lease or find that your IP keeps changing... read on. The first problem is that sdhcp assumes the renew and rebind times will be set. These fields are optional, only the lease time is required. So you may end up never timing out until the lease expires. This can cause you to lose your IP depending on the server. Because the optget() is a relatively expensive call, it is actually cheaper to calculate the times every time. I have attached a patch that does this. The second problem is the server IP. sdhcp assumes that the server id (ODserverid) is the IP of the server. This is not always the case. It seems that the only safe IP is the address from the recvfrom(). Currently sdhcp ignores this value, but it should set server IP to this. I don't have a patch for this since the suckless sdhcp and my sdhcp have diverged a lot here. If you ask nicely I might roll up a patch. All the ODserverid code should be safe to remove. Cheers, Sean diff --git a/sdhcp.c b/sdhcp.c index 1fcf5e6..21e6372 100644 --- a/sdhcp.c +++ b/sdhcp.c @@ -434,12 +434,13 @@ Bound: optget(&bp, mask, OBmask, sizeof(mask)); optget(&bp, router, OBrouter, sizeof(router)); optget(&bp, dns, OBdnsserver, sizeof(dns)); - optget(&bp, &renewaltime, ODrenewaltime, sizeof(renewaltime)); - optget(&bp, &rebindingtime, ODrebindingtime, sizeof(rebindingtime)); optget(&bp, &lease, ODlease, sizeof(lease)); - renewaltime = ntohl(renewaltime); - rebindingtime = ntohl(rebindingtime); lease = ntohl(lease); + /* Renew and rebind times are optional. It is faster to just + * calculate the times. Assumes: lease > 4s and < ~20 years. + */ + renewaltime = lease / 2; + rebindingtime = lease * 7 / 8; acceptlease(); fputs("Congrats! You should be on the 'net.\n", stdout); if (!fflag && !forked) {
Re: [dev][sdhcp] more updates
An update. There is a bug in the raw socket code I posted. It does not try hard enough to make sure that the packet is for us. So it can, and will, end up thinking a different ack is ours. I found this trying to connect to Rogers. If you go to the github (https://github.com/smaclennan/sdhcp) and look at udprecv, I now check the transaction id and the mac address. There are other changes, but this is the only one that really matters. I think it is fixed, but it will take another day before I know for sure. It seems that Rogers does not reply to renewals. They make you go to the rebind state and then ack. Since I have a 48 hour lease, it will take 7/8 of 48 or 42 hours to get a result :( But, I did send a renew and got back an ack for a different computer and successfully ignored it. I also have sdhcp running on the laptop I am using right now and with a 2 hour lease it has been running since Saturday with all renewals working. So I believe the checks are correct. This is one of the few times I wish I had a windows box. It would be interesting to see if Rogers will renew a windows request. I have seen in the past where windows dhcp servers interacted badly with Linux clients. Cheers, Sean
Re: [dev][sdhcp] more updates
I have attached a more complete diff. This diff has Linux raw sockets, portability, and some bug fixes. I have also pushed the changes to github and they can be found here: https://github.com/smaclennan/sdhcp. The diff is quite big, but not really that complicated. The main change is moving all the low level socket calls to util/compat.c. And the bulk of that is the raw udpsend() since you need to build all the headers. So it looks large, but it is really just a lot of simple assignments. IMHO this actually makes sdhcp.c slightly more readable (although it was good before). sdhcp.c has no ifdefs and now really only deals with the DHCP protocol and not socket details. Timers where also moved to compat.c. I have tested the code to work under three main environments: 1) Linux laptops. Just needed raw socket. 2) QNX. Just needed Linux specific code removed and MSG_DONTROUTE flag when sending. This is my main use case for sdhcp. 3) My Linux router connecting to Rogers. For this I needed binary cid support. I also found I had to send the params option or Rogers would not send me the router (GW) address. I have my dhcp server set for a 2 hour lease so the systems (except Rogers) renew after an hour. I instrumented sdhcp so it logged that the renews (and hence the timers) where working. I kept the timerfd API for Linux... it just seems to work better. I use timer_create and a set a wrapper functions for other OSes. I then wrote a compat functions create_timers() that takes a recreate arg. I could detect when it was a recreate, but I think explicitly setting the arg makes it cleaner. The code compiles under FreeBSD (you need -lrt), but doesn't work: sendto fails with network unreachable. I am not a BSD guy, so I didn't even try to fix it. Note that I cheat for non-Linux systems. You must provide a -e script to actually set the IP parameters. With some work this might not be needed, but this is just so much easier. Cheers, Seandiff --git a/Makefile b/Makefile index 7126a36..687e420 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ include config.mk HDR = util.h arg.h LIB = \ + util/compat.o \ util/strlcpy.o \ util/eprintf.o @@ -29,6 +30,8 @@ bin: $(BIN) $(OBJ): $(HDR) config.mk +$(SRC:.c=.o): util.a + .o: @echo LD $@ @$(LD) -o $@ $< util.a $(LDFLAGS) diff --git a/TODO.sam b/TODO.sam new file mode 100644 index 000..af36406 --- /dev/null +++ b/TODO.sam @@ -0,0 +1,4 @@ +* multiple DNS +* domain search +* NTP? +* bring interface up diff --git a/config.mk b/config.mk index 8f32578..bc449eb 100644 --- a/config.mk +++ b/config.mk @@ -10,3 +10,6 @@ LD= $(CC) CPPFLAGS = -D_DEFAULT_SOURCE CFLAGS= -Wall -Wextra -pedantic -std=c99 $(CPPFLAGS) LDFLAGS = -s + +# This is Linux specific +CFLAGS += -DUSE_RAW_SOCKET diff --git a/sdhcp.c b/sdhcp.c index 1fcf5e6..4e0a39f 100644 --- a/sdhcp.c +++ b/sdhcp.c @@ -1,9 +1,9 @@ +#include #include #include -#include #include -#include +#include #include #include @@ -82,23 +82,29 @@ enum { OBend =255, }; -enum { Broadcast, Unicast }; - static Bootp bp; -static unsigned char magic[] = { 99, 130, 83, 99 }; +static const unsigned char magic[] = { 99, 130, 83, 99 }; + +static const unsigned char params[] = { + OBmask, OBrouter, OBdnsserver, ODlease, ODrenewaltime, ODrebindingtime +}; + +/* One socket to rule them all */ +int sock = -1; /* conf */ static unsigned char xid[sizeof(bp.xid)]; -static unsigned char hwaddr[16]; -static char hostname[HOST_NAME_MAX + 1]; +unsigned char hwaddr[ETHER_ADDR_LEN]; +static char hostname[_POSIX_HOST_NAME_MAX + 1]; static time_t starttime; -static char *ifname = "eth0"; -static unsigned char cid[16]; +char *ifname = "eth0"; +static unsigned char cid[24]; +static int cid_len; static char *program = ""; -static int sock, timers[3]; +int timers[N_TIMERS]; /* sav */ -static unsigned char server[4]; -static unsigned char client[4]; +unsigned char server[4]; +unsigned char client[4]; static unsigned char mask[4]; static unsigned char router[4]; static unsigned char dns[4]; @@ -107,8 +113,6 @@ static int dflag = 1; /* change DNS in /etc/resolv.conf ? */ static int iflag = 1; /* set IP ? */ static int fflag = 0; /* run in foreground */ -#define IP(a, b, c, d) (unsigned char[4]){ a, b, c, d } - static void hnput(unsigned char *dst, uint32_t src, size_t n) { @@ -118,7 +122,7 @@ hnput(unsigned char *dst, uint32_t src, size_t n) dst[i] = (src >> (n * 8)) & 0xff; } -static struct sockaddr * +struct sockaddr * iptoaddr(struct sockaddr *ifaddr, unsigned char ip[4], int port) { struct sockaddr_in *in = (struct sockaddr_in *)ifaddr; @@ -130,39 +134,16 @@ iptoaddr(struct sockaddr *ifaddr, unsigned char ip[4], int port) return ifaddr; } -/* sendto UDP wrapper */ -static ssize_t -udpsend(unsigned char ip[4], int fd, void *data, size_t n) -{ - struct sockaddr addr; - socklen_t addrlen = sizeof(addr); - ssize_t sent; - - iptoaddr(&addr, ip, 67); /* b
Re: [dev] [dwm] new release - transition from Openbox
I would say give it a try. After using the same window manager for a long time, I switched to dwm. I tried just about every window manager (ok, probably not true since there are so many obscure ones) but always went back to my favourite. dwm was the only one that stuck and was a big change for me. One of the big pluses is pinning an app to a workspace. When I boot, I get two xterm windows in workspace 1, a browser in workspace 2, and my email client in workspace 3. A change in the config.h I highly recommend is moving the MODKEY from Alt to the Windows key: #define MODKEY Mod4Mask /* windows key */ This doesn't conflict with any apps I use, and it makes sense that the window manager uses the windows key :D Cheers, Sean
Re: [dev][sdhcp] more updates
On Sat, 2 Feb 2019 22:28:33 -0800 Michael Forney wrote: > On 2019-02-02, Sean MacLennan wrote: > > First a question: how portable do we want things? The current sdhcp > > works only on Linux. > > I think that depends on how feasible it is to make it portable without > relying on a bunch of ifdefs to support different platforms. Ok. I will see what I can do with minimal ifdefs. > In terms of timerfd, I think it should be okay to use POSIX timers and > a self-pipe (like that patch I sent you a while back), but it is kind > of ugly to have to recreate the timers after the fork. Personally, I > don't see much value in having sdhcp fork; I always run it with a > service supervisor. Actually, what I did was implement timerfd for BSD (not quite ready yet). I agree that the timerfd code tends to work better on Liunux and I assume Linux is the 90% case. I actually use the fork case most of the time. So I would like to keep it ;) > CLOCK_BOOTTIME is pretty important for being able to resume from > suspend, but I'm not sure how portable this is. It looks like OpenBSD > has it, but not FreeBSD. Maybe this could be an option in a config.h? Good to know. CLOCK_BOOTIME is easy to redefine to CLOCK_MONOTONIC where needed. > > * calctimeout() was dividing the timeout by 2. Not sure why so I > > removed it. Also, the check for less than 60 seconds would only > > work if you went back in time to Jan 1, 1970 for the first > > minute after midnight. > > Check the comment for the calctimeout() function. It sets the > itimerspec passed by the caller to half-way until the expiration of > the specified timer. The struct itimerspec here specifies a time > *duration*, not a time instant, so I don't think 1970 has anything to > do with it. I don't remember the system I checked on, but at least on that system the time read back was absolute I can check again. > The function uses timerfd_gettime to determine the duration of time > left until timer `n` expires, then sets `ts` to half of that duration, > down to a minimum of 60 seconds. This is what RFC 2131 says to do: > >In both RENEWING and REBINDING states, if the client receives no >response to its DHCPREQUEST message, the client SHOULD wait > one-half of the remaining time until T2 (in RENEWING state) and > one-half of the remaining lease time (in REBINDING state), down to a > minimum of 60 seconds, before retransmitting the DHCPREQUEST message. Yes, my mistake. I was now taking into account when calctimeout() was called. I thought it was setting the T1/T2 times... but it is setting the "no response" timeout. Any comment on the raw socket for Linux? Cheers, Sean
[dev][sdhcp] more updates
Not sure if I this list allows attachments... so here we go. First a question: how portable do we want things? The current sdhcp works only on Linux. This patch contains one big change and some smaller changes. The big change is support for raw sockets on Linux. I split the raw socket code into a file called raw.c and included it in sdhcp. I did that only to, hopefully, make the diff more readable. So why raw sockets? Linux has a bug, er design decision, that when you use UDP/TCP sockets it tries really hard to assign an address to the outgoing packet. If you have multiple interfaces, it will actually borrow the address from another interface. This is usually not a problem... except when the dhcp server cannot route local addresses. For example trying to dhcp with Rogers Cable. So a raw socket allows you to force the outgoing address to 0.0.0.0. This code is very Linux specific. I believe it could be forced to work with BSD, but why? BSD doesn't have the problem. You may notice that I close the socket when we are bound. The raw socket sees all traffic on the interface and this is done for performance reasons. Other fixes that are in this diff because I need them: * allow binary cid input. If you put 0x then it will be interpreted as raw bytes. You can still specify a string. * talking about cid, the default is now a correct mac address cid. * calctimeout() was dividing the timeout by 2. Not sure why so I removed it. Also, the check for less than 60 seconds would only work if you went back in time to Jan 1, 1970 for the first minute after midnight. * sdhcp now only prints Congrats on the first connection, not every rebind. * we need the interface up to work. The code now brings the interface up. * a couple of portability cleanups may have crept in too... but I tried to keep them to a minimum. Cheers, Sean diff --git a/raw.c b/raw.c new file mode 100644 index 000..27b7024 --- /dev/null +++ b/raw.c @@ -0,0 +1,158 @@ +#include +#include +#include +#include + +static struct pkt { + struct ether_header ethhdr; + struct ip iphdr; + struct udphdr udphdr; + struct bootp bootp; +} __attribute__((packed)) pkt; + +/* pseudo header for udp calc */ +static struct pseudohdr +{ + unsigned long source_ip; + unsigned long dest_ip; + unsigned char reserved; + unsigned char protocol; + unsigned short udp_length; + struct udphdr udphdr; + struct bootp bootp; +} __attribute__((packed)) pseudohdr; + +static unsigned char server_mac[ETHER_ADDR_LEN]; +static unsigned int ifindex; + +/* RFC 1071. */ +static uint16_t +chksum16(const void *buf, int count) +{ + int32_t sum = 0, shift; + const uint16_t *p = buf; + + while (count > 1) { + sum += *p++; + count -= 2; + } + + if (count > 0) + sum += *p; + + /* Fold 32-bit sum to 16 bits */ + if ((shift = sum >> 16)) + sum = (sum & 0x) + shift; + + return ~sum; +} + +static int +open_socket(void) +{ + struct ifreq ifreq; + int sock, bcast = 1; + + if ((sock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) == -1) + eprintf("socket:"); + + if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &bcast, sizeof(bcast)) == -1) + eprintf("setsockopt broadcast:"); + + memset(&ifreq, 0, sizeof(ifreq)); + strlcpy(ifreq.ifr_name, ifname, IF_NAMESIZE); + + if (ioctl(sock, SIOCGIFINDEX, &ifreq)) + eprintf("SIOCGIFINDEX"); + ifindex = ifreq.ifr_ifindex; + + if (ioctl(sock, SIOCGIFHWADDR, &ifreq)) + eprintf("SIOCGIFHWADDR"); + memcpy(hwaddr, ifreq.ifr_hwaddr.sa_data, sizeof(ifreq.ifr_hwaddr.sa_data)); + + return sock; +} + +static ssize_t +udpsend(int sock, void *data, size_t n, int how) +{ + if (sock == -1) + sock = open_socket(); + + memset(&pkt, 0, sizeof(pkt)); + + if (how == Broadcast) { + memset(pkt.ethhdr.ether_dhost, 0xff, ETHER_ADDR_LEN); + pkt.iphdr.ip_dst.s_addr = INADDR_BROADCAST; + } else { + memcpy(&pkt.ethhdr.ether_dhost, server_mac, ETHER_ADDR_LEN); + memcpy(&pkt.iphdr.ip_dst, server, 4); + } + + memcpy(pkt.ethhdr.ether_shost, hwaddr, ETHER_ADDR_LEN); + pkt.ethhdr.ether_type = ntohs(ETHERTYPE_IP); + + pkt.iphdr.ip_v = 4; + pkt.iphdr.ip_hl = 5; + pkt.iphdr.ip_tos = IPTOS_LOWDELAY; + pkt.iphdr.ip_len = htons(sizeof(struct ip) + sizeof(struct udphdr) + n); + pkt.iphdr.ip_id = 0; + pkt.iphdr.ip_off = htons(0x4000); /* DF set */ + pkt.iphdr.ip_ttl = 16; + pkt.iphdr.ip_p = IPPROTO_UDP; + memcpy(&pkt.iphdr.ip_src, client, 4); + pkt.iphdr.ip_sum = chksum16(&pkt.iphdr, 20); + + pkt.udphdr.uh_sport = htons(68); + pkt.udphdr.uh_dport = htons(67); + pkt.udphdr.uh_ulen = htons(sizeof(struct udphdr) + n); + + memcpy(&pkt.bootp, data, n); + + memset(&pseudohdr, 0, sizeof(pseudohdr)); + pseudohdr.source_ip = pkt.iphdr.ip_src.s_addr; + pseudohdr.dest_ip= pkt.iphdr.ip_dst.s_addr; + pseudohdr.protocol = pkt.iphdr.ip_p; + pseudohdr.udp_length = htons(sizeof(struct udphdr) + n); + + memcpy(&pseudohdr.udphdr, &pkt.udphdr, sizeof(struct udphdr)); + memcpy(&pseudohdr.bootp, data, n); + int header_len = sizeof(pseudohdr)
Re: [dev] xml parser
On Sat, 2 Feb 2019 18:15:26 + sylvain.bertr...@gmail.com wrote: > Hi, > > I am looking at xml parsers. > > I am about to go expat, but I am wondering if there are some > interesting alternatives I did miss? > Json? Not sure what you need the xml parser for... but does it have to be xml? Cheers, Sean
Re: [dev] [dmenu] running shell scripts in dmenu
On Sat, 5 Jan 2019 15:12:41 -0600 Samuel Holland wrote: > For a single-user laptop or workstation, why does there even need to > be a concept of "logging in"? And why do you need 3-4 layers of > shells running in the background to manage your X session? You've got: > - your login shell > - startx > - xinit > - your .xinitrc, if you don't exec your window manager Nice! I really like your setup and I have a laptop in the basement I intend to try this on. The problem is that most of my main laptops are not single-user. My main home laptop I share with my wife, and my work computer I "share" with my official domain login. The idea that I like the most is the udev rule so you don't have to make Xorg +s. It should be doable with just a group, so I could add my wife and I to a group that could run Xorg. Cheers, Sean
Re: [dev] [dmenu] running shell scripts in dmenu
On Sat, 5 Jan 2019 17:09:32 -0200 Caio Barros wrote: > Although I too have a somewhat nostalgic > feeling when typing a command to load the window manager, I don't mind > at all automating it, but for that a DM is not necessary. I almost always run X11... so I want it to startup when I login. Without a DM, this is how I handle it. In your .zlogin or .bash_login or add the following lines: if [ `tty` = /dev/tty1 ]; then startx; clear; logout fi When I login, X11 is started. When I exit X11 (I use Ctrl-Alt-Backspace), I am logged out. Just like a "real" DM. However, if I don't want to start X11 for some reason, just hit Alt-F2 and login. Since you are not on tty1, you will just go to the console. Cheers, Sean
Re: [dev] Yet another "sane alternatives" thread
On Tue, 25 Dec 2018 12:31:50 -0600 Cág wrote: > Wrong. Not even you can compile it with Clang, (HOSTCC=clang > CC=clang), but link it with lld: > http://lists.llvm.org/pipermail/llvm-dev/2017-January/109288.html Sorry, I should have said you can't compile a *working* kernel with clang. They are close though, and I believe they will do it. Cheers, Sean
Re: [dev] Yet another "sane alternatives" thread
On Tue, 25 Dec 2018 08:16:47 -0600 Cág wrote: > I'm thinking of something you can compile the Linux kernel[0] with. The Linux kernel only compiles with the GNU toolchain. There are efforts to get it compiling with clang but I believe they are not there yet. The Linux kernel is portability because the GNU toolchain is portable. Cheers, Sean
Re: [dev] [sdhcp] Part 1/3 Bugs
On Wed, 14 Nov 2018 17:13:15 -0800 Michael Forney wrote: > On 2018-11-12, Sean MacLennan wrote: > > I am surprised you are getting away with binding the socket to the > > broadcast address. > > I found in ip(7): > > INADDR_BROADCAST (255.255.255.255) means any host and has the same > effect on bind as INADDR_ANY for historical reasons. > > So that explains why it worked. Interesting. I obviously hit a case where it doesn't, but that could be a bug on my side. > BTW, is there going to be a part 3/3? > Part 3/3 relies heavily on part 1/3 being accepted ;) Cheers, Sean
[dev] [sdhcp] Part 2/3 Feature request
It would really help the world... ok, me... if the script was given the reason it was being called. Mainly I want to know if it is a renewal. diff --git a/sdhcp.c b/sdhcp.c index e2a641e..b6cbfe7 100644 --- a/sdhcp.c +++ b/sdhcp.c @@ -322,7 +339,7 @@ dhcprecv(void) } static void -acceptlease(void) +acceptlease(const char *reason) { char buf[128]; @@ -341,6 +358,7 @@ acceptlease(void) setenv("ROUTER", buf, 1); snprintf(buf, sizeof(buf), "%d.%d.%d.%d", dns[0], dns[1], dns[2], dns[3]); setenv("DNS", buf, 1); + setenv("REASON", reason, 1); system(program); } alarm(t1); @@ -378,7 +396,7 @@ Requesting: case DHCPoffer: goto Requesting; /* ignore other offers. */ case DHCPack: - acceptlease(); + acceptlease("BOUND"); goto Bound; } Bound: @@ -400,7 +418,7 @@ Bound: Renewing: switch(dhcprecv()) { case DHCPack: - acceptlease(); + acceptlease("RENEW"); goto Bound; case DHCPnak: goto Init; @@ -413,7 +431,7 @@ Rebinding: case DHCPnak: /* lease expired */ goto Init; case DHCPack: - acceptlease(); + acceptlease("REBIND"); goto Bound; } }
[dev] [sdhcp] Part 1/3 Bugs
I am surprised you are getting away with binding the socket to the broadcast address. The other bug is just a simple compiler warning. diff --git a/sdhcp.c b/sdhcp.c index e2a641e..47cabf6 100644 --- a/sdhcp.c +++ b/sdhcp.c @@ -467,7 +467,7 @@ main(int argc, char *argv[]) if (argc) ifname = argv[0]; /* interface name */ if (argc >= 2) - strlcpy(cid, argv[1], sizeof(cid)); /* client-id */ + strlcpy((char *)cid, argv[1], sizeof(cid)); /* client-id */ memset(&ifreq, 0, sizeof(ifreq)); signal(SIGALRM, nop); @@ -482,7 +482,7 @@ main(int argc, char *argv[]) ioctl(sock, SIOCGIFINDEX, &ifreq); if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, &ifreq, sizeof ifreq) == -1) eprintf("setsockopt:"); - iptoaddr(&addr, IP(255, 255, 255, 255), 68); + iptoaddr(&addr, IP(0, 0, 0, 0), 68); if (bind(sock, (void*)&addr, sizeof addr) != 0) eprintf("bind:"); ioctl(sock, SIOCGIFHWADDR, &ifreq);
Re: [dev] [dwm] Emacs ediff popup window does not get focus
So I instrumented dwm with some debugs and found that the terminal was indeed grabbing focus with an enter notify. So I found a workaround within GNU Emacs. Non GNU Emacs users can just look away now. (setf (alist-get 'top ediff-control-frame-parameters) 1) (setf (alist-get 'left ediff-control-frame-parameters) 856) This has been tested on a grand total of one laptop, so left may need to be tweaked. Cheers, Sean
Re: [dev] [dwm] Emacs ediff popup window does not get focus
On Mon, 8 Oct 2018 13:27:23 -0700 AR Garbe wrote: > Hi Sean, > > try forcing that window as floating window via: > > { "Ediff", NULL, NULL, 0,1, > -1 }, > > or > > { "Emacs", "Ediff", NULL, 0,1, > -1 }, > > in the rules[] section of config.h I have already done this. I do get the floating window, it just doesn't get the focus. Cheers, Sean
[dev] [dwm] Emacs ediff popup window does not get focus
At work I have switched from XEmacs to GNU Emacs for various reasons. I use ediff a LOT. With XEmacs, the ediff popup gets the focus but not so with GNU Emacs. The focus always stays in the bottom right window. So I end up with a lot on n characters in that windows (ediff users will understand). Here is the xprop and xwininfo output from Emacs (I cut out the icon): WM_STATE(WM_STATE): window state: Normal icon window: 0x0 WM_HINTS(WM_HINTS): Client accepts input or input focus: True Initial state is Normal State. bitmap id # to use for icon: 0x2de bitmap id # of mask for icon: 0x2e4 window id # of group leader: 0x201 _MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 XdndAware(ATOM) = BITMAP _NET_WM_ICON(CARDINAL) =Icon (48 x 48): _NET_WM_OPAQUE_REGION(CARDINAL) = 7, 0, 130, 7, 0, 7, 144, 35 _NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL _NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 33554612, 33554613 _NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x2b3 WM_CLIENT_LEADER(WINDOW): window id # 0x201 _NET_WM_PID(CARDINAL) = 18570 WM_LOCALE_NAME(STRING) = "C" WM_CLIENT_MACHINE(STRING) = "zonker" WM_NORMAL_HINTS(WM_SIZE_HINTS): user specified location: 0, 0 program specified location: 0, 0 program specified minimum size: 8 by 14 program specified resize increment: 8 by 14 program specified base size: 8 by 14 window gravity: NorthWest WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST WM_CLASS(STRING) = "Ediff", "Emacs" WM_ICON_NAME(STRING) = "Ediff _/4" _NET_WM_ICON_NAME(UTF8_STRING) = "Ediff _/4" WM_NAME(STRING) = "Ediff" _NET_WM_NAME(UTF8_STRING) = "Ediff" xwininfo: Window id: 0x2b2 "Ediff" Absolute upper-left X: 856 Absolute upper-left Y: 1 Relative upper-left X: 856 Relative upper-left Y: 1 Width: 144 Height: 42 Depth: 24 Visual: 0xf4 Visual Class: TrueColor Border width: 1 Class: InputOutput Colormap: 0x21b (not installed) Bit Gravity State: NorthWestGravity Window Gravity State: NorthWestGravity Backing Store State: NotUseful Save Under State: no Map State: IsViewable Override Redirect State: no Corners: +856+1 -918+1 -918-1035 +856-1035 -geometry 17x2+856+1 The main difference I can see from XEmacs is the WM_SIZE_HINTS. XEmacs has a more "normal" looking output. The other hint is that when Emacs creates the ediff window it is seen briefly in the lower right corner as an empty window then moves. With XEmacs it is briefly at the right spanning the two right windows. Any ideas of where to start looking would be greatly appreciated! This is 100% reproducible, so it is easy to get debug information. Cheers, Sean