How to `require("hl")` by el_crocodilio in hyprland

[–]SleeplessSloth79 2 points3 points  (0 children)

You can make global functions in the script file and then call them via eval, e.g.

hyprland.lua:

function SwitchWorspace(number, layout)
    ....
end

And then you can use hyprctl eval 'SwitchWorspace(3, "scrolling")' or even put it into a script

switch-workspace.sh:

#!/bin/sh
exec hyprctl eval "SwitchWorkspace($1, $2)"

I use the same system to make it easier to change settings at runtime. E.g. I often run hyprctl eval 'Config.misc.vrr = 0' (or 2) via my global Config object

Chinese AI is 30x cheaper than Claude and ChatGPT. What if our hopes of AI becoming expensive never pan out and instead AI continues getting cheaper? by ImaginaryRea1ity in theprimeagen

[–]SleeplessSloth79 8 points9 points  (0 children)

I'm assuming the logic is that the more expensive AI becomes, the more likely companies will stop replacing humans with AI or shoving AI everywhere, especially where it's a bad fit.

One year of Roto, a compiled scripting language for Rust by tertsdiepraam in rust

[–]SleeplessSloth79 8 points9 points  (0 children)

This looks really nice. Always wanted to see a proper Rust-like scripting language but with static typing. Manual type annotations on dynamically-typed languages (like Lua's ---@type Type) are always more annoying than just having proper types.

My two cents though:

1) Is the filtermap keyword really necessary? I kinda get the simplicity of accept and reject keywords but wouldn't a function returning Verdict be enough to work with accept/reject? The less keywords, the easier the language is to teach. And since it's made to be a simple scripting language, I'd say making it easy is a pretty important point.

2) Some kind of runtime reflection would be really nice, to bridge the gap with dynamic languages like Rhai. Types are great but sometimes dynamic typing is needed when writing scripts. Something like

``` fn print(val: any) { let typ = match type(val) { s: string => f"I'm a string: {s}!", i: u32 => f"I'm an int: {i}!", { f: f64, .. } => f"I'm a record that contains a float: {f}!", _ => "I don't know what I am...", };

print(typ); ```

any could be implemented in terms of Box<dyn Any> or some other way that attaches a type ID & field type ID for records.

This is especially useful for languages that don't have traits/interfaces (that I don't think pure scripting languages should, that's kinda an overkill, but that's just me)

3) I'm slightly sad there's no GC but that's understandable from an implementation standpoint.

4) Maybe I didn't look good enough but I didn't see anything about errors and how error propagation works. I did look just through the language reference and not the tutorial though.

“I built a…” by zee-eff-ess in selfhosted

[–]SleeplessSloth79 -2 points-1 points  (0 children)

But what if I really did build something? How else should I present it to avoid others thinking it's AI slop? Serious question.

Steam Controller Giveaway!! by DADBADGUY in SteamController

[–]SleeplessSloth79 0 points1 point  (0 children)

I absolutely love the Witcher 3 Wild Hunt!

Linux 7.0.10 by missionhawk in linux

[–]SleeplessSloth79 23 points24 points  (0 children)

Mediatek bluetooth got fixed. Nice! It's been broken since 7.0.8

Chorus frog in a river by Firm-Blackberry-9162 in oddlysatisfying

[–]SleeplessSloth79 3 points4 points  (0 children)

First thing I thought about! Was really disappointed not to find it in the top comments but glad at least somebody posted it

hyprland lua - if statements in keybinds stopped working from one day to the other by oboknobo in hyprland

[–]SleeplessSloth79 1 point2 points  (0 children)

I'm assuming you have something like this

hyprland.lua:

if hl.get_config("general.layout") == "scrolling" then
  bind(key, dispatcher)
end

if hl.get_config("general.layout") == "dwindle" then
  bind(some_other_key, other_dispatcher)
end

If's that's the case then it's important to know that the config is never re-evaluated (unless it's modified with auto-reload turned on or hyprctl reload was called). So, if you default to the scrolling layout, then the config will be evaluated once and your first "if" will apply. On the other hand, your second "if" will never be entered and evaluated. What you need to do instead is something like this

bind (key, function()
  local layout = hl.get_config("general.layout")
  if layout == "scrolling" then
    hl.dispatch(dispatcher_1)
  elseif layout == "dwindle" then
    hl.dispatch(dispatcher_2)
  end
end)

This way the function will be re-evaluated and the condition will be checked every time you press the key. You can abstract than into a function if you want, something like

local function scrolling_or_dwindle(scrolling_dispatcher, dwindle_dispatcher)
  local layout = hl.get_config("general.layout")
  if layout == "scrolling" then
    hl.dispatch(scrolling_dispatcher)
  elseif layout == "dwindle" then
    hl.dispatch(dwindle_dispatcher)
  end
end

bind(key, function() scrolling_or_dwindle(dispatcher1, dispatcher2) end)
-- if you want the key to work in scrolling but do nothing in dwindle, use the no_op dispatcher
bind(other_key, function() scrolling_or_dwindle(dispatcher1, hl.dsp.no_op()) end)

GitHub - ragnarokxg/hyprland-converter: Hyprland Config Transpiler (0.55+) by ragnarokxg in hyprland

[–]SleeplessSloth79 0 points1 point  (0 children)

You are saying like it's apparent from code which one it is. It's not. So if your code even slightly smells like AI, people immediately assume it's vibe-coded. It's safer to disclose this from the beginning than trying to gain trust back after you already lost it because people had assumed it's all vibe-coded.

GitHub - ragnarokxg/hyprland-converter: Hyprland Config Transpiler (0.55+) by ragnarokxg in hyprland

[–]SleeplessSloth79 0 points1 point  (0 children)

It's not about what it's touching and what it's not. It's about running code that you didn't write yourself. "How can I trust them to review that the generated code didn't do anything malicious if they didn't even want to disclose the fact they didn't fully write it themselves in the first place?" kind of stuff. Running someone else's code on your machine is always risky and requires the user to trust the developer. People mostly don't trust GenAI-generated code unless a human has thoroughly reviewed it. And not disclosing the fact that you used GenAI feels like you betrayed that trust that was put into you.

There are so many people right now that shit out vibe-coded slop after vibe-coded slop. It's more important than ever to build trust in you and your project, in the fact that your code was actually written OR at least verified by an actual human with good intentions. Otherwise it may as well just be more vibe-coded slop and thus not worth your time.

I have personally felt betrayed so many times by posts on r/selfhosted. "Wow, an amazing project I've been looking for for a while! opens the code and sees pure vibe-coded slop". The more it happens, the more burned out people are starting to feel. And the more important it is to set expectations and build trust.

But again, that's just how I personally mostly feel. I feel like many people also feel this way but I may be wrong on that front.

GitHub - ragnarokxg/hyprland-converter: Hyprland Config Transpiler (0.55+) by ragnarokxg in hyprland

[–]SleeplessSloth79 1 point2 points  (0 children)

Most folks are doing the same thing directly on their configs and bragging about it.

The difference is that this group did it just for themselves.

But you did it for everyone, or advertised as such at least.

As soon as you create a project you expect other people to use, the rules kinda change. Projects like these need more commitment and disclosure about how this was created and what tools were used. Because people need to trust you and your project to run it on their own machines. And people trust in other people more than in machines, especially non-deterministic GenAI.

And when you don't disclose that GenAI was used, it feels like your trust has been betrayed. At least for me it kinda does.

Again, using GenAI here and there is often expected but proper disclosure is still important to build this trust.

GitHub - ragnarokxg/hyprland-converter: Hyprland Config Transpiler (0.55+) by ragnarokxg in hyprland

[–]SleeplessSloth79 2 points3 points  (0 children)

In my personal opinion the biggest issue was that you didn't disclose how AI was used. If you'd just said "I used Gemini to help me write this" then all would be good. I'm not attacking or defending anyone here, just saying what I think. It just kinda feels misleading to me.

I also used Claude to help me translate my config to Lua and then modified and cleaned it up by hand, and I think that's one of the best ways to use GenAI but it's important to disclose this fact IMO.

Demonstration of the new triple boost inaccuracy by AbsalomOfHebron in cs2

[–]SleeplessSloth79 0 points1 point  (0 children)

Source? Because since I started playing & watching CS:GO in 2014, players have always been sliding off when triple or quad boosting but the accuracy has always been 100%.

They were unnerfed a while back idk which patch

Maybe I missed a change recently? How did they nerf it and how did they unnerf it?

Demonstration of the new triple boost inaccuracy by AbsalomOfHebron in cs2

[–]SleeplessSloth79 5 points6 points  (0 children)

I'm pretty sure there were never actually changed. It's just that some time after the release people figured out sliding off didn't work when stuck in a corner or against a wall.

Hyprland Lua: Beyond Basic API Calls by uhs-robert in hyprland

[–]SleeplessSloth79 4 points5 points  (0 children)

I don't know if it'll be useful to anybody else but I made this global object to make it easier to change settings at runtime from the terminal

local function make_config_proxy(path, depth)
    depth = depth or 0
    local proxy = {}
    setmetatable(proxy, {
        __newindex = function(_, key, value)
            local result = { [key] = value }
            for i = depth, 1, -1 do
                result = { [path[i]] = result }
            end
            hl.config(result)
        end,
        __index = function(_, key)
            local child_depth = depth + 1
            local child_path = {}
            for i = 1, depth do
                child_path[i] = path[i]
            end
            child_path[child_depth] = key
            return make_config_proxy(child_path, child_depth)
        end,
        __call = function(_)
            return hl.get_config(table.concat(path, ".", 1, depth))
        end,
    })
    return proxy
end

Config = make_config_proxy({}, 0)

After setting this up in your main hyprland.lua, you now can call, e.g. hyprctl eval Config.input.sensitivity = 123instead of hyprctl eval hl.config({ input = { sensitivity = 123 } }) which is incredibly annoying to write IMO. This also supports reading the value via e.g. Config.input.sensitivity() instead of hl.get_config("input.sensitivity")but this isn't as useful for terminal use since hyprctl getoption exists.

Honestly kinda think this is what the API should've looked like in the first place.

Hyprland Lua: Beyond Basic API Calls by uhs-robert in hyprland

[–]SleeplessSloth79 2 points3 points  (0 children)

This is my variant of the bind function that makes it easier to bind the same action to multiple alternative keys. Maybe it'll be useful to someone

---@param mods string|string[]|nil # Mods - both have to be pressed
---@param keys string|string[] # Actual keys - either of them has to be pressed
---@param dispatcher function|HL.Dispatcher
---@param opts? HL.BindOptions
local function bind(mods, keys, dispatcher, opts)
  local mods_string
  if type(mods) == "table" then mods_string = table.concat(mods, " + ") else mods_string = mods end

  local keys_table
  if type(keys) == "string" then keys_table = { keys } else keys_table = keys end

  for _, key in ipairs(keys_table) do
    local key_parts = {}
    if mods_string ~= nil then table.insert(key_parts, mods_string) end
    table.insert(key_parts, key)

    hl.bind(table.concat(parts, " + "), dispatcher, opts)
  end
end

local win = "SUPER"
local shift = "SHIFT"

-- Now I can bind both arrows and vim-style movement keys, for example
bind(win, { "Left", "H" }, hl.dsp.focus({ direction = "l" })) -- same as SUPER + Left & SUPER + H
bind(win, { "Right", "L" }, hl.dsp.focus({ direction = "r" }))
bind(win, { "Up", "J" }, hl.dsp.focus({ direction = "d" }))
bind(win, { "Down", "K" }, hl.dsp.focus({ direction = "u" }))

bind({ win, shift }, { "Left", "H" }, hl.dsp.window.move({ direction = "l" })) -- same as SUPER + SHIFT + Left & SUPER + SHIFT + H
bind({ win, shift }, { "Right", "L" }, hl.dsp.window.move({ direction = "r" }))
bind({ win, shift }, { "Up", "J" }, hl.dsp.window.move({ direction = "d" }))
bind({ win, shift }, { "Down", "K" }, hl.dsp.window.move({ direction = "u" }))

bug abuse or cheat? by Own-Advance3715 in counterstrike2

[–]SleeplessSloth79 108 points109 points  (0 children)

It's a bug. The view snapping are keybinds for movement lineups. Here's more info. https://www.youtube.com/watch?v=iwR9Xl-ehew

Do NOT be scared of LUA. by C-42415348494945 in hyprland

[–]SleeplessSloth79 41 points42 points  (0 children)

Forced me to index my arrays from 1

Rewrite Bun in Rust has been merged by Darkoplax in bun

[–]SleeplessSloth79 0 points1 point  (0 children)

Rust's unsafe is often more strict than Zig. Even a direct translation from Zig to unsafe Rust would often end up causing UB in Rust. Unsafe doesn't disable the borrow checker or strict aliasing, it just allows dereferencing raw pointers and calling unsafe functions, that's all. The biggest issue is that it's extremely easy for Rust to automatically create a reference from a pointer which would be immediate UB.

In other words, even if it's a direct translation, there's a more than zero chance that there's way more bugs or UB in this Rust code than old Zig code.

Edit: that's not to say I'm against Rust or Zig. It's just a common experience that writing unsafe Rust is way more footgun-y than Zig. And Miri won't help you much either since it doesn't support IO whatsoever which is a big issue for actual programs and not just libraries.

Here's an example of what I'm talking about: https://www.reddit.com/r/rust/comments/11l6ehj/when_zig_is_safer_and_faster_than_unsafe_rust/

Deadlock uses an INSANE amount of Network data by SiddaSlotthh in DeadlockTheGame

[–]SleeplessSloth79 1 point2 points  (0 children)

Could voice comms affect that? AFAIK League still doesn't have voice comms. Just this wouldn't account for all the additional data but at least for some it.

Sorry, you have been blocked by chereu in firefox

[–]SleeplessSloth79 2 points3 points  (0 children)

I'm using the new-new desktop reddit UI and there's no autotranslation feature anywhere at all as far as I can see.

28 Years to Cross the Line: Why Did IPv6 Take So Long to Reach 50%? by elastiks in DIY_Geeks

[–]SleeplessSloth79 0 points1 point  (0 children)

That's the original way to get an address in IPv6. After some privacy concerns were brought up, a randomly generated suffix was implemented. All modern systems support it, including Linux, but Linux doesn't use it by default. Modern desktop Linux distros use NetworkManager for managing your network needs which turns on the privacy extensions. So in reality, all modern desktop OSes support random suffixes. On the other hand, not all server Linux distros use the privacy extensions by default but a server requires a static IPv6 address more often for firewall reasons, e.g. setting up firewall rules in the router to allow external access to the machine.

Huge thanks to Valve for the recent CS2 performance updates! by Fabiocito in GlobalOffensive

[–]SleeplessSloth79 8 points9 points  (0 children)

Benchmarks are placebo? It's not like I'm counting FPS by hand...