Threads for pfr

  1. 3

    hk is pretty interesting per se ! And your knowledge of ffmpeg format conversion and post-processing is really valuable, and I’ll steal a good bit of it 😉

    I’ve been using a combination of wmutils and xrectsel to do something similar. I extend upon your solution by having the ability to record a randomly selected region of the screen, or arbitrary coordinates. I’m using different tools for that, which are more specific than simple xwindow output parsing (which is far from ideal IMO).

    • xrectsel lets you draw a region on the screen, and reports coordinates
    • slw / pfw (from wmutils) both report an X window ID (either selected by clicking it, or using the focused one)
    • wattr reports various window attributes (xywhb gives X, Y, Width, Height, Border width)
    • randr is a hacky tool I wrote to report the monitor size where the mouse cursor is (useful on multi-monitor setups)

    Here’s a showcase : ffmpeg-coordinate.webm

    1. 1

      Lovely and simple, as always. I’d love to steal that snip screenshot script off you ;)

      1. 3
        #!/bin/sh
        # require imagemagick, xrectsel
        png=$(mktemp -p /tmp x11-snip.XXXXXXXX.png)
        import -window root $png
        convert $png -crop $(xrectsel '%wx%h+%x+%y') $png
        printf '%s' "$png" | xsel # Optional, put image path in clipboard for convenience
        display $png
        
        1. 1

          Thanks! I tried searching for your rec script too but can’t find where you keep such things. Can you please share a link? I’m quite interested to see your script and learn how you do it vs the script in the article. Cheers

          1. 1

            I don’t share them online, that’s why you couldn’t find anything. The rec script is basically them same as the above, but using ffmpeg rather than convert. And OP’s ffmpeg and are much better in terms of quality than what I came up with.

    1. 1

      Solve this problem with a simple shell function:

      # usage: unzip <file>
      unzip () {
        if [ -f $1 ] ; then
          case $1 in
            *.tar.bz2)    tar xjf $1    ;;
            *.tar.gz)     tar xzf $1    ;;
            *.tar.xz)     tar xf $1     ;;
            *.tar)        tar xf $1     ;;
            *.tar.zst)    uzstd $1      ;;
            *.bz2)        bunzip2 $1    ;;
            *.rar)        unrar x $1    ;;
            *.gz)         gunzip $1     ;;
            *.tbz2)       tar xjf $1    ;;
            *.tgz)        tar xzf $1    ;;
            *.zip)        unzip $1      ;;
            *.Z)          uncompress $1 ;;
            *.7z)         7z x $1       ;;
            *.deb)        ar x $1       ;;
            *)    echo "'$1' cannot be extracted via ex()" ;;
          esac
        else
          echo "'$1' is not a valid file"
        fi
      }
      
      1. 1

        I see bellcore… did it use MGR? That was a neat little windowing system with a bunch of interesting ideas.

        1. 1

          There was definitely an X port. I can’t remember if MGR was available or not though I wouldn’t be surprised.

          1. 2

            Coherent got X11 before it got TCP/IP. The X11 programs were compiled to use a library that provided IP over named pipes rather than using the network. I don’t remember there ever being a commercial networking stack for the product from Mark Williams. Someone did successfully add TCP/IP after Mark Williams went out of business. I dimly remember an AT&T MGR port but I could be wrong.

            I wish that the effort that went into making X11 work had been used for TCP/IP networking instead. I believe that X11 would have been easier to port if TCP/IP was available and the delay would have also meant working with a later version of XFree86. XFree86 was improving rapidly at that time so the delay would have meant better quality code all around. It didn’t work out that way for a lot of reasons. The X11 vs networking issue seems like a big blunder but looking back with a realistic eye toward the fog of war reveals that the decision was not controversial at all. It should have been clear that TCP/IP would be a big player in networking between 1993 and 1997 but earlier on it wasn’t obvious that TCP/IP would subsume and replace all other networks.

            The mid ‘90s were a weird time in Unix. There were a handful of sanctioned AT&T Unix OS’s for the i386. I remember SCO, Interactive Unix, and Xenix to mention 3. Bill Jolitz and his wife had just released 386BSD. There was Coherent which, ran on both the 286 and the 386, and wasn’t based on AT&T code. Coherent had been reviewed and vetted as such by Dennis Ritchie. And obviously, Linux had just appeared.

            1. 2

              Calling out all greybeards, can we get a MGR port to NetBSD, pretty please!?

          2. 1

            MGR

            AFAIK, no.

            There was a 3rd party X server, for X11R5: https://www.autometer.de/unix4fun/coherent/third_party.html

            A relatively recent look at Coherent: https://virtuallyfun.com/wordpress/2017/12/19/coherent-3-0/

            Later the company did its own version – here’s the manual: https://www.nesssoftware.com/home/mwc/doc/coherent/x/pdf/X11.pdf

          1. 2

            Just because this kind of ancient stuff interests me, Id be keen to try out MGR on NetBSD. I wonder if anyone has attempted to port/package it before. Anyone here have any hints on how someone might go about getting MGR on a *BSD system?

            1. 2

              Hey, I really enjoyed reading your article and discovering your website, along with your other projects. We have very similar taste it seems. I’m going to email you! :D

              1. 1

                looking forward to it :3

              1. 1

                For starters you need an Arcan build that comes straight from the source. The things needed here are really new, not covered by any release, and is actively worked on. Arcan is a pain to build from source and, if you want it to replace your entire display server, also a pain to setup. Twice the fun.

                So, I wonder what the viability of an Arcan based distro would be? I get that maintenance is probably the bottle neck here, but what would be truly amazing, and would open the door for all of your average Joe’s to try this out, would be to release a preconfigured Linux distribution that runs Arcan out of the box. Sure, this might be asking a lot, but this would be the ticket in for many faint hearted onlookers.

                1. 1

                  I think the bigger problem is IMHO, coming up with introductory materials. Everything I read about Arcan feels like a cipher, and I should definitely understand windowing systems (even if most of my experience is elsewhere).

                1. 1

                  Not super interesting I reckon. But the ones I use the most.

                  ..='cd ..'
                  ip='ip -br -c'
                  home='git --work-tree=/home/fox --git-dir=/home/fox/.config/home.git'
                  
                  i3conf='vim ~/.config/i3/config'
                  zshrc='vim ~/.config/zsh/.zshrc && source ~/.config/zsh/.zshrc'|
                  

                  I don’t really have a lot of super useful aliases. Most of the time is spent making git config aliases and vim stuff.

                  1. 1

                    Is that BSD or a mac? My ip doesn’t know either flag.

                    1. 2

                      That is iproute2. The goal is to have ip be brief by default because I simply do not care about all the information.

                      λ ~ » /usr/bin/ip a
                      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
                          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
                          inet 127.0.0.1/8 scope host lo
                             valid_lft forever preferred_lft forever
                          inet6 ::1/128 scope host
                             valid_lft forever preferred_lft forever
                      2: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
                          link/ether 10:3d:1c:e9:f5:cf brd ff:ff:ff:ff:ff:ff
                          inet 192.168.1.11/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp0s20f3
                             valid_lft 78751sec preferred_lft 78751sec
                          inet6 fe80::9f2c:5a98:d8ef:b06e/64 scope link noprefixroute
                             valid_lft forever preferred_lft forever
                      3: enp0s31f6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
                          link/ether 90:2e:16:5e:1a:b5 brd ff:ff:ff:ff:ff:ff
                      14: enp36s0u1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
                          link/ether 00:50:b6:9f:fe:25 brd ff:ff:ff:ff:ff:ff
                      
                      λ ~ » ip a
                      lo               UNKNOWN        127.0.0.1/8 ::1/128
                      wlp0s20f3        UP             192.168.1.11/24 fe80::9f2c:5a98:d8ef:b06e/64
                      enp0s31f6        DOWN
                      enp36s0u1        DOWN
                      
                      1. 1

                        Thanks, but that’s why I was asking:

                        ii  iproute2                              5.5.0-1ubuntu1
                        

                        ip -br doesn’t work and neither does ip -c or ip -br -c.

                        And now I finally grasped that it would output the same as 'ip' - so it is -brief -color. Sorry, brainfart (ofc I searched before I asked that last question..) :P

                        Apparently I have never used either flag and didn’t notice them in the manual. – signed, someone gowing up with ifconfig

                        1. 1

                          Yeah I found the documentation for these commands a bit lacking when I started utilizing them initially.

                    2. 1

                      ..='cd ..'

                      I was going to post this as my most useful, because I just it all the time.

                      I also have ...="cd ../.." and so on for going up more levels. Probably not useful beyond four or five levels due to how quickly can you count how deep you are in the CWD.

                      Edit: Just to be clear, I’m talking about me visually counting up how many levels deep I am in the directory tree. Beyond three or four, I tend to just go up that much, and then look and see where I am and maybe do it again, with my finger hovering over the ‘.’ key. I don’t have a problem rapidly tapping out the ‘.’ nine times to go up 8 levels, the difficulty (for me) is determining that I want to go up 8, vs. 7 or 9 levels.

                      1. 1

                        Don’t want to keep posting it so I’ll link to the reply i made to the parent:

                        https://lobste.rs/s/qgqssl/what_are_most_useful_aliases_your_bashrc#c_fqu7jd

                        You might like to use it too!

                      2. 1

                        You (and others) might be interested in the one from my post to this:

                        function up() {
                          local d=""
                          limit=$1
                          for ((i=1 ; i <= limit ; i++))
                            do
                              d=$d/..
                            done
                          d=$(echo $d | sed 's/^\///')
                          if [ -z "$d" ]; then
                            d=..
                          fi
                          cd $d
                        }
                        

                        Allows you to just do up 4 to get cd ../../../..

                        LIFE-saver.

                        1. 2

                          Even more fun (only works in zsh, as far as I know):

                          function rationalize-dot {
                              if [[ $LBUFFER = *... ]]; then
                                  LBUFFER=${LBUFFER[1,-2]}
                                  LBUFFER+=/..
                              else
                                  LBUFFER+=.
                              fi
                           }
                           zle -N rationalize-dot
                           bindkey . rationalize-dot
                          

                          You can make this even better by adding setopt auto_cd to your config, so that if you type a directory path zsh automatically changes to that directory.

                          1. 1

                            I tend to use https://github.com/wting/autojump for smart CDing, personally!

                          2. 2
                            alias .="cd .."
                            alias ..="cd ../.."
                            alias ...="cd ../../.."
                            alias ....="cd ../../../.."
                            
                            1. 1

                              Interesting. I’ve never tried to install / use those “smart” cd replacements, where you can type “cd foobar” and it looks at your recent working directories to find a “foobar” and go there.

                              I was thinking about a variant of your up function that does something like that, where I can type “up foo” in the current directory:

                              /home/username/foobar/one/two/three/four/
                              

                              And so it just looks into successive parent directories for anything matching “foo”, and the first one it finds is the destination.

                              1. 2

                                oh man – just use Autojump https://github.com/wting/autojump. I use it on every machine i own and it’s a GODSEND.

                                1. 1

                                  That was what I was talking about. I’ll have to give it or maybe zoxide a try and see if I stick with it.

                          1. 2

                            Related, I use this snippet every now and again to see what commands I am using a lot to see if I can generate aliases for them.

                            history | cut -f 7- -d " " | sort | uniq -c | sort | tail -20

                            1. 1

                              I have an alias to search the shell’s command history using fzf (on ksh) then copy it to the clipboard

                              alias h='fc -l -n -r 1 | nuniq | sed -Ee "s/^[[:blank:]]+//" | fzf | xclip -selection c'
                              
                            1. 2

                              I’m kind of surprised this hasn’t been mentioned yet, it’s bee around for some time and certainly is one of the most useful features in my .scrc

                              # ARCHIVE EXTRACTION
                              # usage: ex <file>
                              ex () {
                                if [ -f $1 ] ; then
                                  case $1 in
                                    *.tar.bz2)    tar xjf $1    ;;
                                    *.tar.gz)     tar xzf $1    ;;
                                    *.tar.xz)     tar xf $1     ;;
                                    *.tar)        tar xf $1     ;;
                                    *.tar.zst)    uzstd $1      ;;
                                    *.bz2)        bunzip2 $1    ;;
                                    *.rar)        unrar x $1    ;;
                                    *.gz)         gunzip $1     ;;
                                    *.tbz2)       tar xjf $1    ;;
                                    *.tgz)        tar xzf $1    ;;
                                    *.zip)        unzip $1      ;;
                                    *.Z)          uncompress $1 ;;
                                    *.7z)         7z x $1       ;;
                                    *.deb)        ar x $1       ;;
                                    *)    echo "'$1' cannot be extracted via ex()" ;;
                                  esac
                                else
                                  echo "'$1' is not a valid file"
                                fi
                              }
                              

                              Another little one I often use which is useful if you are making edits to files and keeping backups of originals:

                              # swap 2 filenames around, if they exist
                              # usage: swap <file1> <file2>
                              swap () {
                                  local TMPFILE=tmp.$$
                                  mv "$1" $TMPFILE
                                  mv "$2" "$1"
                                  mv $TMPFILE "$2"
                              }
                              
                                1. 2

                                  Or from a different angle, tree-sitter:text-editors::llvm:compilers

                                  1. 2

                                    There is also zed which is still in early development. Written in Rust by the creators of Atom, the Real-Time collaboration looks pretty interesting!

                                    1. 2

                                      Ah, looks like the zed team also built tree-sitter?

                                      1. 2

                                        Not only the name is almost the same, in fact zee’s feature list ends with: “a pragmatic editor, not a research endeavour into CRDTs” which -I suspect- is a clear reference to zed.

                                        1. 2

                                          I took that as more of a dig at xi-editor, but I’ve known about that longer than I’ve known about zed.

                                      2. 1

                                        IMO emacs is about the introspection and customization more than the keybindings (which is why I use evil-mode :) ).

                                        It’s definitely interesting that both helix and zee are terminal editors. I think that prevents you from doing a lot of ‘cool’ things like widgets with arbitrary graphics or embedding a markdown preview, but I think the only ‘reasonable’ choices for cross-platform are either Qt or Electron. And if you want people to be able to make widgets easily without having to learn a bespoke scripting system, you’re basically stuck with Electron. :/

                                      1. 1

                                        ThinkPad X230

                                        1. 3

                                          I’m curious what his comission on this job was.

                                          1. 1

                                            I rarely use nano these days but back in 2020 I requested a ‘set notitlebar’ option on savannah which didnt really get much support. Now they’ve implemented ‘–zero’ option which is sweet for some basic editing on small screens without the all the cruft. Now we just need Doom-nano, nano with vim-like keybindings ( ._.) edit: spelling

                                            1. 16

                                              Cool. How can I turn it off? I use Firefox’s Dark Reader extension to theme all pages the same colour. I would appreciate a toggle for the lobste.rs dark mode please.

                                              1. 6

                                                no new registrations? :(

                                                1. 2

                                                  Invitation only? This either needs to be part of lobsters or someone needs to start sharing the love.

                                                1. 4

                                                  That’d be so cool if this were just integrated into lobsters.

                                                  1. 1

                                                    Great idea!

                                                  1. 2

                                                    Heck yes! This is awesome and I will buy this laptop and install SculptOS!

                                                    1. 3

                                                      Nice to see the screenshot of Falkon Browser featuring the MNT Reform! Here’s hoping that an ARM based SculptOS image is developed for the Reform!

                                                      EDIT: I just found this: https://genode.org/documentation/release-notes/20.08

                                                      1. 1

                                                        UNIX running inside a Windows XP VM running on Windows 7… lol Cool project though, good for a dose of nostalgia.