Recently i got a monitor (thx stardance) and connected it to my laptop right away , but my hyprland didnt had anything to assign to the moniter , so it just went with the default one ,a diff workspace and i had to configure it a lot then finally got it to work but now i think i will make a rust based cli tool to automate those things . Easy right? for users not me lol .
see the poc :
distroller list
distroller use 1 (here 1 means the 1st moniter like for laptop , it is eDP-1, while the other moniters will turn off maybe? define the state in distroller.conf )
distroller use 2 (HDMI-A-1)
distroller use 1,2… (it gives each moniter diff workspace)
distroller use 1,2 –share (it makes both share a workspace but more like a single monitor )
distroller use 1,2 –copy (show the same thing)
i made it a codeblock but the comments () arent valid so dont copy these things ,
now imma gonna start building the base
so built the initial struct , btw i used u8 for height and width at first but it doesnt store 1920 or 1080 so i used u16 as it is better than u32 atleast i think so , also i used f32 for the refreash rate as hyprland give things like 59.64 sometimes , wait wtf am i explain? its basics nah i dont needa explain, nah, i’wd build .
ok added another struct to copy the vals to new struct wait wait , why am i such a fool? why did i made a struct to js push a value to next struct? wait i again figured a thing , i can js follow the hyprctl output’s structure lol ,
[erox@archbtw ~]$ hyprctl monitors -j
[{
“id”: 0,
“name”: “eDP-1”,
“description”: “BOE 0x094A”,
“make”: “BOE”,
“model”: “0x094A”,
“width”: 1920,
“height”: 1080,
“physicalWidth”: 340,
“physicalHeight”: 190,
“refreshRate”: 60.00400,
“x”: 0,
“y”: 0,
“activeWorkspace”: {
“id”: 1,
“name”: “1”
},
{
“id”: 1,
“name”: “HDMI-A-1”,
“description”: “XXX HDMI”,
“make”: “XXX”,
“model”: “HDMI”,
“serial”: “”,
“width”: 1920,
“height”: 1080,
“physicalWidth”: 10,
“physicalHeight”: 10,
“refreshRate”: 60.00000,
“x”: 1280,
“y”: 0,
“activeWorkspace”: {
“id”: 4,
“name”: “4”
},]
[erox@archbtw ~]$
made the best struct
pub struct Disp {
pub name: String,
pub refreshRate: f32,
pub w: u16,
pub h: u16,
pub focused: bool,
pub disabled: bool,
}
now just gonna fetch frm the hyprctl output and print done
ok added the code to run hyprlctl monitors -j and fetch the info , but then i got err js because i forgot to add the deserializer and then after i fixed lol cargo toml didnt have derde lol , and now i imported it as macro another lol , and now i forgot to import the feature deserialize with serde .
bruh this time i js got a err of version mismatch tht was added by cargo , how life can be worser?
ohhh it worked finally :
but wait the 2nd moniter was supposed to be 100hz default , ik its downsampled because of the other moniter , anyways i ’ll fix tht later hmhm now imma gonna make the other features .
okk broke main.rs and made ls.rs and main.rs , currently i kept the hypr func (the one to execute hyprctl with structed args as u want ) in ls as idh any hypr.rs , but i will soon move tht to somewhere else as ls.rs is for listing only , yeah thts why i named it ls , i didnt steal the name of ls bash command , wait i kinda did to be honest .ok after a lot of research , i found hyprctl eval ‘hl.monitor({ output = “eDP-1”, disabled = true })’ works to turn of the display so i can make a function inside my new io.rs and use it to turn off on on the display hmhm.
now imma gonna work on the turn off and on function
done it works , i js used hyprctl command to do it , it wasnt much hard
after finding some repos i found this hyprctl eval ‘hl.monitor({ output = “eDP-1”, disabled = true })’ it ran well so i made a file named
io.rs and implanted on main done and now it works though its not usable on terminal , cargo run does the work fine .