hallettj

joined 8 months ago
[–] hallettj@leminal.space 4 points 6 hours ago

For TNG I'd suggest Identity Crisis. That one freaked me out more than any Trek I can recall.

14
submitted 4 days ago* (last edited 4 days ago) by hallettj@leminal.space to c/linux@lemmy.ml
 

Some app launchers these days run each app in a new systemd scope, which puts the app process and any child processes into their own cgroup. For example I use rofi which does this, and I noticed that fuzzel does also. That is handy for tracking and cleaning up child processes!

You can see how processes are organized by running,

$ systemctl --user status

I think that's a quite useful way to see processes organized. Looking at it I noticed a couple of scopes that shouldn't still be running.

Just for fun I wanted to use this to try to script a better killall. For example if I run $ killscope slack I want the script to:

  1. find processes with the name "slack"
  2. find the names of the systemd scopes that own those processes (for example, app-niri-rofi-2594858.scope)
  3. kill processes in each scope with a command like, systemctl --user stop app-niri-rofi-2594858.scope

Step 2 turned out to be harder than I liked. Does anyone know of an easy way to do this? Ideally I'd like a list of all scopes with information for all child processes in JSON or another machine-readable format.

systemctl --user status gives me all of the information I want, listing each scope with the command for each process under it. But it is not structured in an easily machine-readable format. Adding --output json does nothing.

systemd-cgls shows the same cgroup information that is shown in systemctl --user status. But again, I don't see an option for machine-readable output.

systemd-cgtop is interesting, bot not relevant.

Anyway, I got something working by falling back on the classic commands. ps can show the cgroup for each process:

$  ps x --format comm=,cgroup= | grep '^slack\b'
slack           0::/user.slice/user-1000.slice/user@1000.service/app.slice/app-niri-rofi-2594858.scope
slack           0::/user.slice/user-1000.slice/user@1000.service/app.slice/app-niri-rofi-2594858.scope
slack           0::/user.slice/user-1000.slice/user@1000.service/app.slice/app-niri-rofi-2594858.scope
...

The last path element of the cgroup happens to be the scope name. That can be extracted with awk -F/ '{print $NF}' Then unique scope names can be fed to xargs. Here is a shell function that puts everything together:

function killscope() {
    local name="$1"
    ps x --format comm=,cgroup= \
        | grep "^$name\b" \
        | awk -F/ '{print $NF}' \
        | sort | uniq \
        | xargs -r systemctl --user stop
}

It could be better, and it might be a little dangerous. But it works!

[–] hallettj@leminal.space 5 points 5 days ago (3 children)

I'd rather listen to Raditude than Pinkerton...

[–] hallettj@leminal.space 5 points 1 week ago (1 children)

I lived in Grenada for a couple of years. It's a chill, safe place. I had my family there and we always felt safe, as long as we kept an eye out for speeding buses when crossing the street. It certainly checks the boxes you specified. Night life is limited. I'm planning to go back for a vacation in February.

As I recall there is a time of year that gets very windy. I think that's in winter, but my memory is fuzzy. The internet says February is the windiest, and that matches some of my memories. In any case it's always warm. I wouldn't worry about rain. That's tapered off by December. If it does rain it's a warm rain, and it's likely to come in short showers so I don't think you'd be stuck inside all day.

If you want to be in walking distance to amenities I'd recommend staying near Grand Anse. You can also get public buses there. (They are actually vans.) There are resorts close to the airport, but in those places you'd be dependent on taxis to get away from the resort - which might be fine if you want to be somewhere quieter.

[–] hallettj@leminal.space 3 points 1 week ago

When I researched this previously I concluded that there are two very good options for regular backups: Borg and Restic. These are especially efficient at backing up a diff of what has changed since the last backup. So you get snapshots of your filesystem state at each backup point without using a huge amount of space. You can mount any snapshot as a virtual directory. After the initial backup, incremental backups take a minute or two.

I use Borg, and I back up to cloud storage on Borgbase. I use Vorta as a GUI for Borg. I have Vorta start automatically when I start my window manager, and I have it set up for daily backups. I set up the same thing on my kid's computer.

I back up my home directory. I have some excluded directories like ~/.cache, and Steam's data directory. I use Baobab to find large directories that I don't want backed up.

I use the "exclude caches" option in the Borg "create archive" settings. That automatically excludes Rust target/ directories because they follow the Cache Directory Tagging Specification. Not all programming languages' tooling follows that spec so I also use directory name pattern excludes. For example I have an exclude pattern for .*/node_modules/.*

I use NixOS, and I keep my system config in a git repo so I don't need backups for anything outside my home directory.

[–] hallettj@leminal.space 16 points 2 weeks ago (1 children)

What I'm hearing is shepherds' pie, but spherical

[–] hallettj@leminal.space 28 points 2 weeks ago (6 children)

According to the theory of quantum immortality, everyone gets their own main-character timeline.

[–] hallettj@leminal.space 1 points 2 weeks ago

I made a rendering of a lighthouse on the Dark Ocean in 3D Studio Max. Or I guess it would be better called a darkhouse. Unfortunately that image is lost to time.

[–] hallettj@leminal.space 9 points 3 weeks ago (2 children)

I enjoyed Digimon as a teenager. I never got any cards. However I did make a liiiittle fan art.

[–] hallettj@leminal.space 41 points 3 weeks ago

In the episode where he wore that outfit he held the Enterprise hostage, froze two crew members, and threatened to wipe out humanity.

 

A short post on how variable names can leak out of macros if there is a name collision with a constant. I thought this was a delightful read!

[–] hallettj@leminal.space 2 points 1 month ago

I thought so too, but my wife said, "Nope nope nope"

 

Difftastic is a diff tool that uses treesitter parsing to compare code AST nodes instead of comparing lines. After following the instructions for use with git I'm seeing some very nice diffs when I run git diff or run git show --ext-diff. I thought it would be nice to get the same output for hunk diffs in the fugitive status window, and in fugitive buffers in general (which use the git filetype). But I haven't seen any easy way to do it. Has anyone got a setup like this?

I can run a command in neovim like :Git show --ext-diff to get difftastic output in a buffer. I'm thinking maybe I can set up fugitive to use the --ext-diff flag by default, or set up some aliases. But there is no syntax highlighting for the difftastic outputs since the ANSI color codes that difftastic uses in interactive terminal output don't work in neovim, and the syntax highlighting for the git filetype assumes standard diff output which is not compatible with difftastic output. For me losing colors is not a worthwhile trade for the otherwise more readable diff output.

My best idea right now is to set up a new filetype called difftastic, and write a new treesitter grammar or syntax plugin for it. Then set up some kind of neovim configuration to feed output from difftastic into buffers with the new filetype.

There is an open neovim issue discussing adding syntax-aware diffs directly to neovim, but that doesn't seem to have gone anywhere.

 

cross-posted from: https://leminal.space/post/4750886

It took me some time to work out how to get my ssh agent set up in Niri so I though I would share what I did. I'm using NixOS and Home Manager. I put this in my Home Manager config:

services.gnome-keyring = {
  enable = true;
  components = [ "pkcs11" "secrets" "ssh" ];
};
home.sessionVariables.SSH_AUTH_SOCK = "$XDG_RUNTIME_DIR/keyring/ssh";

I'm using GDM according to NixOS' default configuration which I think runs gnome-keyring (I thought I saw it in the process list before I set up the user unit), and I think that configuration is automatically unlocking gnome-keyring when I log in via PAM integration. But apparently I need to run gnome-keyring again in my window manager session. Home Manager's services.gnome-keyring adds a systemd user unit that does that.

2
submitted 7 months ago* (last edited 7 months ago) by hallettj@leminal.space to c/neovim@programming.dev
 

I'd like a treesitter query that matches a Rust struct together with all of its attributes. For example,

#[derive(Debug)]
#[serde(rename_all = "camel_case")]
pub struct MyType {
    pub foo: i32,
}

The lines beginning with # are attributes that are logically connected to the struct declaration. But the treesitter grammar for Rust parses attributes as adjacent nodes, not as children of the struct declaration:

  (attribute_item ; [27, 0] - [27, 16]
    (attribute ; [27, 2] - [27, 15]
      (identifier) ; [27, 2] - [27, 8]
      arguments: (token_tree ; [27, 8] - [27, 15]
        (identifier)))) ; [27, 9] - [27, 14]
  (attribute_item ; [28, 0] - [28, 35]
    (attribute ; [28, 2] - [28, 34]
      (identifier) ; [28, 2] - [28, 7]
      arguments: (token_tree ; [28, 7] - [28, 34]
        (identifier) ; [28, 8] - [28, 18]
        (string_literal)))) ; [28, 21] - [28, 33]
  (struct_item ; [29, 0] - [31, 1]
    (visibility_modifier) ; [29, 0] - [29, 3]
    name: (type_identifier) ; [29, 11] - [29, 17]
    body: (field_declaration_list ; [29, 18] - [31, 1]
      (field_declaration ; [30, 4] - [30, 16]
        (visibility_modifier) ; [30, 4] - [30, 7]
        name: (field_identifier) ; [30, 8] - [30, 11]
        type: (primitive_type)))) ; [30, 13] - [30, 16]

How can I get produce a query that I can use in mini.ai that matches the struct, and all attributes?

I've tried this query using Neovim's new built-in :EditQuery command:

((attribute_item)* . (struct_item)) @custom_capture.outer

It looks like it does what I want. But when I try using @custom_capture.outer in mini.ai it matches the struct declaration, but not the attributes.

I tried using #make-range! like this,

((attribute_item)* @_start . (struct_item) @_end
  (#make-range! "custom_capture.outer" @_start @_end))

That matches the struct and the second attribute, but does not get the first attribute. I'm guessing that's because the . specifies that nodes must be adjacent, and the second attribute is the only one that is adjacent to a struct_item. Following that thinking I tried this,

((attribute_item)? @_start . (attribute_item)* . (struct_item) @_end
  (#make-range! "custom_capture.outer" @_start @_end))

That gets the struct and all the attributes, but only if my cursor is on the first attribute line when I use the textobject. If my cursor is on any subsequent line then I get the second attribute and the struct, but the first attribute is missed.

One problem is I'm not clear whether ((attribute_item) . (struct_item)) matches an attribute_item and a struct_item that are adjacent, or matches an attribute_item that precedes a struct_item, but does not also match the struct_item. I tried experimenting with the second interpretation and used this query,

(((attribute_item) 
  . [(attribute_item) (struct_item)])* @_start
  (struct_item) @_end
  (#make-range! "custom_capture.outer" @_start @_end))

That captures what I want, but in some cases if I have two struct declarations and I try to match only the second one the query selects both structs instead.

Is that the way to do a lookahead? Or is there another way?

I've kinda hit a wall looking at documentation, other examples, and running my own experiments. Does anyone have any pointers to help understand these queries on a deeper level?

Edit: It looks like this stuff is in flux, so I should mention that I'm using the latest nightly as of March 2 2024, and I made sure that all of my plugins are up-to-date.

view more: next ›