From 8cc8094fc24b79f33131515f56d50a9ed37356ca Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:30:54 +0000 Subject: [PATCH 01/23] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 759ac34..6799361 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ # lidm -Lidm is a really light display manager made in C, highly customizable and held together by hopes and prayers šŸ™ +LiDM is a really light display manager made in C, highly customizable and held together by hopes and prayers šŸ™. ![demo image](assets/lidm.gif) -> *this is shown as in a terminal emulator, actual linux console doesn't support as much color and decorations* +> *this is shown as in a terminal emulator, actual linux console doesn't support as much color and decorations.* -> *but all colors and strings are fully customizable* +> *but all colors and strings are fully customizable.* -> *I'm open if anybody wants to contact me to record a proper demo of the program, my laptop can't handle it and idk how to config obs for hyprland (ended up doing it, spent 40min processing a 2min video just to give 1fps)* +> *I'm open if anybody wants to contact me to record a proper demo of the program, my laptop can't handle it and idk how to config obs for hyprland (ended up doing it, spent 40min processing a 2min video just to give 1fps.* # Index (TODO, VSC(odium) does this automatically, I'm on nvim rn šŸ˜Ž) ## Features -* Builds fast af -* Works everywhere you can get gcc to compile -* Fast and possibly efficient +* Builds fast AF. +* Works everywhere you can get gcc to compile. +* Fast and possibly efficient. * Fully customizable, from strings, through action keys, to colors (I hope you know ansi escape codes) * Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (if enabled in config) @@ -46,7 +46,7 @@ The name is just ly but changing "y" with "i", that had a reason but forgot it, ![think gif](https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExcTFzaGVmb3VjN3FnOXV6OG9rMG91a2QwM3c0aDV0NWpoZjFzNDEwayZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/d3mlE7uhX8KFgEmY/giphy.gif) -Btw, this laptop is so bad that I can't even render markdown in reasonable time, I'll just push this and fix render issues live :) +FYI, this laptop is so bad that I can't even render markdown in reasonable time, I'll just push this and fix render issues live :) # Requirements * A computer with unix based system. From 849cc4c3e5c20afd636864e66667a4bfd48d186c Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:31:57 +0000 Subject: [PATCH 02/23] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6799361..8af9608 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ LiDM is a really light display manager made in C, highly customizable and held t * desktop's file `TryExec` key * Save last selection * Show/hide passwd switch -* Long sessions, strings, usernames, passwords... they will just overflow or f\*ck your terminal, I know it and I don't know if I'll fix it. +* Long sessions, strings, usernames, passwords... they will just overflow or fuck your terminal, I know it and I don't know if I'll fix it. ## Forget it * Any kind of arguments @@ -93,6 +93,11 @@ Special thanks to: * If this ~~video~~ **repo** gets to 100 ~~likes~~ **stars**, I'll make an arch aur package and properly document installation on multiple init systems. * (I might also make a nix flake if yall nix nerds ask me for it) +# Contributors +* DeaDvey +* killertfus +* Javalsai + # Recommendations Hope you didn't expect actual project recommendations, but these songs are šŸ”„ * "Sixpence None the Richer - Kiss Me" From ea1d2cbdb2a2febc61e80104497f25f678004231 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:33:47 +0000 Subject: [PATCH 03/23] Update README.md --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8af9608..03e8fd7 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ We all know that the most important thing in a project is the ideology of the au > *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz)* # Backstory -I went into summer travel to visit family with an old laptop that barely supports x86_64, and ly recently added some avx2 instructions I think (I just get invalid op codes), manually building (any previous commit too) didn't work because of something in the `build.zig` file, so out of boredom I decided to craft up my own simple display manager on the only language this thing can handle, ✨C✨ (I hate this and reserve the right for the rust rewrite, actually solid). +I travelling in the summer to visit family with an old laptop that barely supports x86_64, and ly recently added some avx2 instructions I think (I just get invalid op codes), manually building (any previous commit too) didn't work because of something in the `build.zig` file, so out of boredom I decided to craft up my own simple display manager on the only language this thing can handle, ✨C✨ (I hate this and reserve the right for the rust rewrite, actually solid). I spedrun it, basically did in in 3 days on the same couch on [unhelty back positions (even worse)](https://i.redd.it/4bkje8amisu61.png) while touching *some* grass (:o), and I'm bad af in C, so this is spaghetti code on **another** level. I think it doesn't do almost anything unsafe, I mean, I didn't check allocations and it's capable of reallocating memory until your username uses all memory and crashes the system due to a off by 1 error, but pretty consistent otherwise (probably). @@ -86,6 +86,7 @@ This is also GPLv3 bcs I was too lazy to look for the "do anything I don't care" # Contributors Special thanks to: +* DeaDvey, the most awesomest and so is first on this list. * ChatGPT, in times of slow laptops where pages take ages to load, a single tab connected to a bunch of burning cloud GPUs feeding corporate hype is all you need to get quick answers for your questions, as long as you know how to filter AI crap ofc. * [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq/?igsh=NO_ZUCKERBERG__FUCK_OFF_YOUR_FINGERPRINGTING_QUERY__OBVIOUSLY_STANDS_FOR_INSTAGRAM_SHARE_ID_FFS), can't imagine this project being possible if somebody actually cared about me daily. @@ -93,11 +94,6 @@ Special thanks to: * If this ~~video~~ **repo** gets to 100 ~~likes~~ **stars**, I'll make an arch aur package and properly document installation on multiple init systems. * (I might also make a nix flake if yall nix nerds ask me for it) -# Contributors -* DeaDvey -* killertfus -* Javalsai - # Recommendations Hope you didn't expect actual project recommendations, but these songs are šŸ”„ * "Sixpence None the Richer - Kiss Me" From 3f2fec5a4244232a8fbfd9f0f1f0add7c8bf4822 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:40:31 +0000 Subject: [PATCH 04/23] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 03e8fd7..de059e8 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ This is also GPLv3 bcs I was too lazy to look for the "do anything I don't care" # Contributors Special thanks to: * DeaDvey, the most awesomest and so is first on this list. +* KillerTofus, [made the AUR package](https://github.com/javalsai/lidm/pull/2)! * ChatGPT, in times of slow laptops where pages take ages to load, a single tab connected to a bunch of burning cloud GPUs feeding corporate hype is all you need to get quick answers for your questions, as long as you know how to filter AI crap ofc. * [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq/?igsh=NO_ZUCKERBERG__FUCK_OFF_YOUR_FINGERPRINGTING_QUERY__OBVIOUSLY_STANDS_FOR_INSTAGRAM_SHARE_ID_FFS), can't imagine this project being possible if somebody actually cared about me daily. From 511deb64cd18dbd59dd9672d352a76a252637755 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:43:55 +0000 Subject: [PATCH 05/23] Update README.md Did it in first person so it looks like you wrote it, like the rest of the readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de059e8..eb4a1a5 100644 --- a/README.md +++ b/README.md @@ -86,8 +86,9 @@ This is also GPLv3 bcs I was too lazy to look for the "do anything I don't care" # Contributors Special thanks to: -* DeaDvey, the most awesomest and so is first on this list. -* KillerTofus, [made the AUR package](https://github.com/javalsai/lidm/pull/2)! +* Javalsai, Maintainer and everyone's second favourite penguin!!! +* DeaDvey, the most awesomest of all. +* KillerTofus, [made the AUR package](https://github.com/javalsai/lidm/pull/2)! Saved me from reading the Arch Wiki šŸ’€. * ChatGPT, in times of slow laptops where pages take ages to load, a single tab connected to a bunch of burning cloud GPUs feeding corporate hype is all you need to get quick answers for your questions, as long as you know how to filter AI crap ofc. * [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq/?igsh=NO_ZUCKERBERG__FUCK_OFF_YOUR_FINGERPRINGTING_QUERY__OBVIOUSLY_STANDS_FOR_INSTAGRAM_SHARE_ID_FFS), can't imagine this project being possible if somebody actually cared about me daily. From 589fa928fc2d8b64aaa4ddd7996621769f45aba2 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:51:07 +0000 Subject: [PATCH 06/23] Update README.md Changed "Compiling" to "Building from source" --- README.md | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index eb4a1a5..04188ba 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ LiDM is a really light display manager made in C, highly customizable and held t > *I'm open if anybody wants to contact me to record a proper demo of the program, my laptop can't handle it and idk how to config obs for hyprland (ended up doing it, spent 40min processing a 2min video just to give 1fps.* # Index -(TODO, VSC(odium) does this automatically, I'm on nvim rn šŸ˜Ž) +(TODO, VSC(odium) does this automatically, I'm on nvim rn šŸ˜Ž). ## Features * Builds fast AF. @@ -19,13 +19,13 @@ LiDM is a really light display manager made in C, highly customizable and held t * Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (if enabled in config) ## WIP -* desktop's file `TryExec` key -* Save last selection -* Show/hide passwd switch +* desktop's file `TryExec` key. +* Save last selection. +* Show/hide passwd switch. * Long sessions, strings, usernames, passwords... they will just overflow or fuck your terminal, I know it and I don't know if I'll fix it. ## Forget it -* Any kind of arguments +* Any kind of arguments. * UTF characters, I'm using `strlen()` and treating characters as per byte basis, UTF-8 chars might work or not actually, might fix it by replacing some `strlen()` with a utflen one. > [!CAUTION] @@ -35,7 +35,7 @@ LiDM is a really light display manager made in C, highly customizable and held t We all know that the most important thing in a project is the ideology of the author and the movements he wants to support, so [**#stopchatcontrol**](https://stopchatcontrol.eu). [ ![stopchatcontrol](https://stopchatcontrol.eu/wp-content/uploads/2023/09/1-1-1024x1024.png) ](https://stopchatcontrol.eu) -> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz)* +> *there's also a [change.org post](https://www.change.org/p/stoppt-die-chatkontrolle-grundrechte-gelten-auch-im-netz).* # Backstory I travelling in the summer to visit family with an old laptop that barely supports x86_64, and ly recently added some avx2 instructions I think (I just get invalid op codes), manually building (any previous commit too) didn't work because of something in the `build.zig` file, so out of boredom I decided to craft up my own simple display manager on the only language this thing can handle, ✨C✨ (I hate this and reserve the right for the rust rewrite, actually solid). @@ -46,30 +46,32 @@ The name is just ly but changing "y" with "i", that had a reason but forgot it, ![think gif](https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExcTFzaGVmb3VjN3FnOXV6OG9rMG91a2QwM3c0aDV0NWpoZjFzNDEwayZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/d3mlE7uhX8KFgEmY/giphy.gif) -FYI, this laptop is so bad that I can't even render markdown in reasonable time, I'll just push this and fix render issues live :) +FYI, this laptop is so bad that I can't even render markdown in reasonable time, I'll just push this and fix render issues live :). # Requirements * A computer with unix based system. -* That system should have the resources neccessary for this program to make sense (sessions, users...) -* A compiler (optional, you can compile by hand, but I doubt you want to see the code) -* Make (also optional, but does things atomatically, make sure `gcc` and `mkdir -p` work as expected) +* That system should have the resources neccessary for this program to make sense (sessions, users...). +* A compiler (optional, you can compile by hand, but I doubt you want to see the code). +* Make (also optional, but does things atomatically, make sure `gcc` and `mkdir -p` work as expected). # Usage On top of pure intuition: -* you can change focus of session/user/passwd with up/down arrows -* in case arrow keys do nothing on the focused input (either is empty text or doesn't have more options), it tries to change session and if there's only one session it changes user -* typing anything will allow to put a custom user or shell command too, you can use arrow keys to move -* ESC and then left/right arrows will force to change the option of the focused input, useful if you're editing the current input and arrow keys just move -* editing a predefined option on a user or a shell session, will put you in edit mode preserving the original value, other cases start from scratch +* you can change focus of session/user/passwd with up/down arrows. +* in case arrow keys do nothing on the focused input (either is empty text or doesn't have more options), it tries to change session and if there's only one session it changes user. +* typing anything will allow to put a custom user or shell command too, you can use arrow keys to move. +* ESC and then left/right arrows will force to change the option of the focused input, useful if you're editing the current input and arrow keys just move. +* editing a predefined option on a user or a shell session, will put you in edit mode preserving the original value, other cases start from scratch. -# Compiling +# Building from source ```sh +git clone https://github.com/javalsai/lidm.git +cd lidm make # šŸ‘ ``` # Installation * You can put the compiled binary anywhere you want tbh, you can even setuid it if you want to run it with any user, but code's not too safe 😬. -* Prepare the [configuration](#configuring) +* Prepare the [configuration](#configuring). * Make a service file for this if you want it on launch, just check how ly does it, this works pretty much the same way. # Configuring @@ -77,7 +79,7 @@ Copy any `.ini` file from [`themes/`](./themes/) (`default.ini` will always be u Also configurable colors are just gonna be put inside `\x1b[...m`, ofc you can add an m to break this and this can f* up really bad or even make some nice UI effect possible, but please don't, you should also be able to embed the `\x1b` byte in the config as I won't parse escape codes, I think that the parser is just gonna grab anything in the config file from the space after the `=` (yes, I'ma enforce that space, get good taste if you don't like it) until the newline, you can put any abomination in there. -Btw, the default fg style should disable decorators set up in other elements (cursive, underline... it's just adding 20 to the number btw, so if cursive is 4 (iirc), disabling it is 24). +The default fg style should disable decorators set up in other elements (cursive, underline... it's just adding 20 to the number btw, so if cursive is 4 (iirc), disabling it is 24). # Contributing Don't do this to yourself, but you can ofc, you can also fork or whatever (make sure to comply with GNU's GPLv3), but I want to do the rust rewrite 😔 (after it, I'll leave this around in case somebody with ancient hardware needs it, or if somebody wants to port it for a microwave...) @@ -87,17 +89,17 @@ This is also GPLv3 bcs I was too lazy to look for the "do anything I don't care" # Contributors Special thanks to: * Javalsai, Maintainer and everyone's second favourite penguin!!! -* DeaDvey, the most awesomest of all. +* DeaDvey, the most awesomest of all, did some pretty HARDCORE gramer cheking. * KillerTofus, [made the AUR package](https://github.com/javalsai/lidm/pull/2)! Saved me from reading the Arch Wiki šŸ’€. * ChatGPT, in times of slow laptops where pages take ages to load, a single tab connected to a bunch of burning cloud GPUs feeding corporate hype is all you need to get quick answers for your questions, as long as you know how to filter AI crap ofc. * [My lack of gf](https://www.instagram.com/reel/C8sa3Gltmtq/?igsh=NO_ZUCKERBERG__FUCK_OFF_YOUR_FINGERPRINGTING_QUERY__OBVIOUSLY_STANDS_FOR_INSTAGRAM_SHARE_ID_FFS), can't imagine this project being possible if somebody actually cared about me daily. # Milestones * If this ~~video~~ **repo** gets to 100 ~~likes~~ **stars**, I'll make an arch aur package and properly document installation on multiple init systems. -* (I might also make a nix flake if yall nix nerds ask me for it) +* (I might also make a nix flake if yall nix nerds ask me for it). # Recommendations -Hope you didn't expect actual project recommendations, but these songs are šŸ”„ +Hope you didn't expect actual project recommendations, but these songs are šŸ”„: * "Sixpence None the Richer - Kiss Me" * "Avril Lavigne - Complicated" * "Shawn Mendes - There's Nothing Holdin' Me Back" From 2891bf855a20673c1154bbb7e879d6d6f808a561 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:56:43 +0000 Subject: [PATCH 07/23] Update README.md Capitalised first letter in () --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 04188ba..2a789c1 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,24 @@ LiDM is a really light display manager made in C, highly customizable and held together by hopes and prayers šŸ™. ![demo image](assets/lidm.gif) -> *this is shown as in a terminal emulator, actual linux console doesn't support as much color and decorations.* +> *This is shown as in a terminal emulator, actual linux console doesn't support as much color and decorations.* -> *but all colors and strings are fully customizable.* +> *But all colors and strings are fully customizable.* -> *I'm open if anybody wants to contact me to record a proper demo of the program, my laptop can't handle it and idk how to config obs for hyprland (ended up doing it, spent 40min processing a 2min video just to give 1fps.* +> *I'm open if anybody wants to contact me to record a proper demo of the program, my laptop can't handle it and idk how to config obs for hyprland (Ended up doing it, spent 40min processing a 2min video just to give 1fps).* # Index (TODO, VSC(odium) does this automatically, I'm on nvim rn šŸ˜Ž). ## Features -* Builds fast AF. +* Builds fast af. * Works everywhere you can get gcc to compile. * Fast and possibly efficient. * Fully customizable, from strings, through action keys, to colors (I hope you know ansi escape codes) -* Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (if enabled in config) +* Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (If enabled in config) ## WIP -* desktop's file `TryExec` key. +* Desktop's file `TryExec` key. * Save last selection. * Show/hide passwd switch. * Long sessions, strings, usernames, passwords... they will just overflow or fuck your terminal, I know it and I don't know if I'll fix it. @@ -29,7 +29,7 @@ LiDM is a really light display manager made in C, highly customizable and held t * UTF characters, I'm using `strlen()` and treating characters as per byte basis, UTF-8 chars might work or not actually, might fix it by replacing some `strlen()` with a utflen one. > [!CAUTION] -> (they should add `> [!DISCLAIMER]` fr) I wrote this readme with the same quality as the code, behing this keyboard there's half a brainrotcell left writing what it remembers of this program, so don't take this to seriously, I'm typing as I think without filter lol, but the program works, or should. Also, about any "TODO" in this readme (or the code), I didn't forget finishing it, I actually don't care. And, references to ~~code~~ **anything** are likely to be outdated, check the commit history to know what I was refering to exactly if you care. +> (They should add `> [!DISCLAIMER]` fr) I wrote this readme with the same quality as the code, behing this keyboard there's half a brainrotcell left writing what it remembers of this program, so don't take this to seriously, I'm typing as I think without filter lol, but the program works, or should. Also, about any "TODO" in this readme (Or the code), I didn't forget finishing it, I actually don't care. And, references to ~~code~~ **anything** are likely to be outdated, check the commit history to know what I was refering to exactly if you care. # Ideology We all know that the most important thing in a project is the ideology of the author and the movements he wants to support, so [**#stopchatcontrol**](https://stopchatcontrol.eu). @@ -40,9 +40,9 @@ We all know that the most important thing in a project is the ideology of the au # Backstory I travelling in the summer to visit family with an old laptop that barely supports x86_64, and ly recently added some avx2 instructions I think (I just get invalid op codes), manually building (any previous commit too) didn't work because of something in the `build.zig` file, so out of boredom I decided to craft up my own simple display manager on the only language this thing can handle, ✨C✨ (I hate this and reserve the right for the rust rewrite, actually solid). -I spedrun it, basically did in in 3 days on the same couch on [unhelty back positions (even worse)](https://i.redd.it/4bkje8amisu61.png) while touching *some* grass (:o), and I'm bad af in C, so this is spaghetti code on **another** level. I think it doesn't do almost anything unsafe, I mean, I didn't check allocations and it's capable of reallocating memory until your username uses all memory and crashes the system due to a off by 1 error, but pretty consistent otherwise (probably). +I spedrun it, basically did in in 3 days on the same couch on [unhelty back positions (even worse)](https://i.redd.it/4bkje8amisu61.png) while touching *some* grass (:o), and I'm bad af in C, so this is spaghetti code on **another** level. I think it doesn't do almost anything unsafe, I mean, I didn't check allocations and it's capable of reallocating memory until your username uses all memory and crashes the system due to a off by 1 error, but pretty consistent otherwise (Probably). -The name is just ly but changing "y" with "i", that had a reason but forgot it, (maybe the i in *simple*), so I remembered this sh*tty laptop with a lid, this thing is also a display manager (dm, ly command is also `ly-dm`), so just did lidm due to all that. +The name is just ly but changing "y" with "i", that had a reason but forgot it, (maybe the i in *simple*), so I remembered this sh*tty laptop with a lid, this thing is also a display manager (Dm, ly command is also `ly-dm`), so just did lidm due to all that. ![think gif](https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExcTFzaGVmb3VjN3FnOXV6OG9rMG91a2QwM3c0aDV0NWpoZjFzNDEwayZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/d3mlE7uhX8KFgEmY/giphy.gif) @@ -50,17 +50,17 @@ FYI, this laptop is so bad that I can't even render markdown in reasonable time, # Requirements * A computer with unix based system. -* That system should have the resources neccessary for this program to make sense (sessions, users...). +* That system should have the resources neccessary for this program to make sense (Sessions, users...). * A compiler (optional, you can compile by hand, but I doubt you want to see the code). -* Make (also optional, but does things atomatically, make sure `gcc` and `mkdir -p` work as expected). +* Make (Also optional, but does things atomatically, make sure `gcc` and `mkdir -p` work as expected). # Usage On top of pure intuition: -* you can change focus of session/user/passwd with up/down arrows. -* in case arrow keys do nothing on the focused input (either is empty text or doesn't have more options), it tries to change session and if there's only one session it changes user. -* typing anything will allow to put a custom user or shell command too, you can use arrow keys to move. +* You can change focus of session/user/passwd with up/down arrows. +* In case arrow keys do nothing on the focused input (Either is empty text or doesn't have more options), it tries to change session and if there's only one session it changes user. +* Typing anything will allow to put a custom user or shell command too, you can use arrow keys to move. * ESC and then left/right arrows will force to change the option of the focused input, useful if you're editing the current input and arrow keys just move. -* editing a predefined option on a user or a shell session, will put you in edit mode preserving the original value, other cases start from scratch. +* Editing a predefined option on a user or a shell session, will put you in edit mode preserving the original value, other cases start from scratch. # Building from source ```sh From 5367e697c535af4bd2b345f5325efd722f9ecfe9 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:57:05 +0000 Subject: [PATCH 08/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a789c1..0e5ac91 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lidm +# LiDM LiDM is a really light display manager made in C, highly customizable and held together by hopes and prayers šŸ™. ![demo image](assets/lidm.gif) From d38ca16477d0d9b86c1237e6ab23982989cfe30f Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 02:03:01 +0000 Subject: [PATCH 09/23] Removed the beg for help --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 0e5ac91..8276166 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ LiDM is a really light display manager made in C, highly customizable and held t > *But all colors and strings are fully customizable.* -> *I'm open if anybody wants to contact me to record a proper demo of the program, my laptop can't handle it and idk how to config obs for hyprland (Ended up doing it, spent 40min processing a 2min video just to give 1fps).* - # Index (TODO, VSC(odium) does this automatically, I'm on nvim rn šŸ˜Ž). From 8c108ee8ca758e1f30e6285b06f0a96d63c6f034 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 02:33:10 +0000 Subject: [PATCH 10/23] Added docs for systemd --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 8276166..bbd6fc1 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ LiDM is a really light display manager made in C, highly customizable and held t * Fast and possibly efficient. * Fully customizable, from strings, through action keys, to colors (I hope you know ansi escape codes) * Automatically detects xorg and wayland sessions, plus allowing to launch the default user shell (If enabled in config) +* Starts with many init systems eg: systemd and dinit. ## WIP * Desktop's file `TryExec` key. @@ -72,6 +73,20 @@ make # šŸ‘ * Prepare the [configuration](#configuring). * Make a service file for this if you want it on launch, just check how ly does it, this works pretty much the same way. +# Starting with SystemD +* Starting lidm with SystemD is not fully supported, however it will start on launch. +In the lidm directory run these commands: +```sh +sudo cp li.service /etc/systemd/system +sudo systemdtl enable li +``` +You may also want to disable your current Display Manager for instance: +```sh +sudo systemctl disable sddm # Disables SDDM (KDE's dm) +sudo systemctl disable lightdm # Disables lightDM (popular lightweight DM) +sudo systemctl disable gdm # Disables GDM (Gnomes DM) +``` + # Configuring Copy any `.ini` file from [`themes/`](./themes/) (`default.ini` will always be updated) to `/etc/lidm.ini` and/or configure it to your liking. Also, don't place empty lines (for now). From 36296c55ec5d570b63482815fd32fce8db5ad771 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 02:33:45 +0000 Subject: [PATCH 11/23] Removed bullet point --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bbd6fc1..7c64046 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ make # šŸ‘ * Make a service file for this if you want it on launch, just check how ly does it, this works pretty much the same way. # Starting with SystemD -* Starting lidm with SystemD is not fully supported, however it will start on launch. +Starting lidm with SystemD is not fully supported, however it will start on launch. In the lidm directory run these commands: ```sh sudo cp li.service /etc/systemd/system From 4fb00e46dcbc2f7e51ddb4bdb877283a1192b0d5 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 02:35:23 +0000 Subject: [PATCH 12/23] Create li.service --- li.service | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 li.service diff --git a/li.service b/li.service new file mode 100644 index 0000000..b3c76a0 --- /dev/null +++ b/li.service @@ -0,0 +1,17 @@ +[Unit] +Description=TUI display manager +After=systemd-user-sessions.service plymouth-quit-wait.service +After=getty@tty3.service +Conflicts=getty@tty3.service + +[Service] +Type=idle +ExecStart=$HOME/git/lidm/assets/li.service +StandardError=journal +StandardInput=tty +TTYPath=/dev/tty3 +TTYReset=yes +TTYVHangup=yes + +[Install] +Alias=display-manager.service From 117593f5ec0c42b25719c81993545e4485d1b930 Mon Sep 17 00:00:00 2001 From: DeaDvey Date: Fri, 26 Jul 2024 03:41:18 +0100 Subject: [PATCH 13/23] moved li.service --- li.service => assets/li.service | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename li.service => assets/li.service (100%) diff --git a/li.service b/assets/li.service similarity index 100% rename from li.service rename to assets/li.service From 53da9b70f723b47d09c140856bf30d2cdfafab5d Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 02:43:48 +0000 Subject: [PATCH 14/23] Updated sytemd docs --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c64046..8c2892c 100644 --- a/README.md +++ b/README.md @@ -75,9 +75,12 @@ make # šŸ‘ # Starting with SystemD Starting lidm with SystemD is not fully supported, however it will start on launch. -In the lidm directory run these commands: +Firstly, edit the assets/li.service file to have the corrent path of the lidm binary. +eg: +```ExecStart=$HOME/git/lidm/lidm``` +Then, in the lidm directory run these commands: ```sh -sudo cp li.service /etc/systemd/system +sudo cp assets/li.service /etc/systemd/system sudo systemdtl enable li ``` You may also want to disable your current Display Manager for instance: From 691996ff7f4e820ed50e804853653e331b94bf19 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 02:44:45 +0000 Subject: [PATCH 15/23] Spelling --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c2892c..301c36b 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ make # šŸ‘ # Starting with SystemD Starting lidm with SystemD is not fully supported, however it will start on launch. -Firstly, edit the assets/li.service file to have the corrent path of the lidm binary. +Firstly, edit the assets/li.service file to have the correct path of the lidm binary. eg: ```ExecStart=$HOME/git/lidm/lidm``` Then, in the lidm directory run these commands: From cb853cb379f0db592907a36d6cdad0e22a9dfdc1 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 02:45:17 +0000 Subject: [PATCH 16/23] Aesthetics --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 301c36b..5687a4e 100644 --- a/README.md +++ b/README.md @@ -85,9 +85,9 @@ sudo systemdtl enable li ``` You may also want to disable your current Display Manager for instance: ```sh -sudo systemctl disable sddm # Disables SDDM (KDE's dm) +sudo systemctl disable sddm # Disables SDDM (KDE's dm) sudo systemctl disable lightdm # Disables lightDM (popular lightweight DM) -sudo systemctl disable gdm # Disables GDM (Gnomes DM) +sudo systemctl disable gdm # Disables GDM (Gnomes DM) ``` # Configuring From e1c5122071611253d03ecf4ba99504a0bd8ca946 Mon Sep 17 00:00:00 2001 From: DeaDvey <104674266+DeaDvey@users.noreply.github.com> Date: Fri, 26 Jul 2024 03:04:10 +0000 Subject: [PATCH 17/23] Change install instructions --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5687a4e..f3e4d80 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ On top of pure intuition: git clone https://github.com/javalsai/lidm.git cd lidm make # šŸ‘ +sudo make install ``` # Installation @@ -75,10 +76,7 @@ make # šŸ‘ # Starting with SystemD Starting lidm with SystemD is not fully supported, however it will start on launch. -Firstly, edit the assets/li.service file to have the correct path of the lidm binary. -eg: -```ExecStart=$HOME/git/lidm/lidm``` -Then, in the lidm directory run these commands: +In the lidm directory run these commands: ```sh sudo cp assets/li.service /etc/systemd/system sudo systemdtl enable li From a15b49ec24e334a7b326cca250b38c788c3f5c9f Mon Sep 17 00:00:00 2001 From: DeaDvey Date: Fri, 26 Jul 2024 04:15:11 +0100 Subject: [PATCH 18/23] detects if systemd is there --- Makefile | 10 ++++++++++ assets/li.service | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6336bcf..7ad642b 100644 --- a/Makefile +++ b/Makefile @@ -24,3 +24,13 @@ lidm: $(OBJ) .PHONY: clean clean: rm -f $(ODIR)/*.o *- li $(INCDIR)/*- + +# Copy lidm to /usr/bin +install: lidm + install -m 755 lidm /usr/bin + if command -v systemctl &> /dev/null; then \ + echo "Systemd exists, copying service file"; \ + cp assets/li.service /etc/systemd/system/; \ + else \ + echo "No systemd"; \ + fi diff --git a/assets/li.service b/assets/li.service index b3c76a0..ffe405c 100644 --- a/assets/li.service +++ b/assets/li.service @@ -6,7 +6,7 @@ Conflicts=getty@tty3.service [Service] Type=idle -ExecStart=$HOME/git/lidm/assets/li.service +ExecStart=/usr/bin/lidm StandardError=journal StandardInput=tty TTYPath=/dev/tty3 From 93f14f398e5be74fd48aaa65e50e6e65737526f1 Mon Sep 17 00:00:00 2001 From: DeaDvey Date: Fri, 26 Jul 2024 04:18:20 +0100 Subject: [PATCH 19/23] removed systemd guide, no longer needed --- README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f3e4d80..08fc412 100644 --- a/README.md +++ b/README.md @@ -74,18 +74,13 @@ sudo make install * Prepare the [configuration](#configuring). * Make a service file for this if you want it on launch, just check how ly does it, this works pretty much the same way. -# Starting with SystemD -Starting lidm with SystemD is not fully supported, however it will start on launch. -In the lidm directory run these commands: -```sh -sudo cp assets/li.service /etc/systemd/system -sudo systemdtl enable li -``` -You may also want to disable your current Display Manager for instance: +# Disabling other DM's with systemd +You may want to disable your current Display Manager for instance: ```sh sudo systemctl disable sddm # Disables SDDM (KDE's dm) sudo systemctl disable lightdm # Disables lightDM (popular lightweight DM) sudo systemctl disable gdm # Disables GDM (Gnomes DM) +sudo systemctl disable ly # Disables LYDM (tui dm) ``` # Configuring From 844687809b7958d1c12ad80ec708157ee45154f4 Mon Sep 17 00:00:00 2001 From: javalsai Date: Fri, 26 Jul 2024 14:25:22 +0200 Subject: [PATCH 20/23] fix: missing \n (added perror too) --- src/sessions.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/sessions.c b/src/sessions.c index eb2437c..8b8f14b 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -40,6 +40,7 @@ static u_int16_t used_size = 0; static struct session *sessions = NULL; static struct sessions_list *__sessions_list = NULL; +// NOTE: commented printf's here would be nice to have debug logs if I ever implement it static enum session_type session_type; static int fn(const char *fpath, const struct stat *sb, int typeflag) { // practically impossible to reach this @@ -47,12 +48,14 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) { if (used_size == 0xffff) return 0; - if (!S_ISREG(sb->st_mode)) + if (sb == NULL || !S_ISREG(sb->st_mode)) return 0; + /*printf("gonna open %s\n", fpath);*/ FILE *fd = fopen(fpath, "r"); if (fd == NULL) { - fprintf(stderr, "error opening file (r) %s", fpath); + perror("fopen"); + fprintf(stderr, "error opening file (r) %s\n", fpath); return 0; } @@ -63,6 +66,7 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) { char *exec_buf = NULL; char *tryexec_buf = NULL; while (true) { + /*printf(".");*/ char *buf = malloc(sb->st_blksize); ssize_t read_size = getline(&buf, &alloc_size, fd); if (read_size == -1) { @@ -91,11 +95,13 @@ static int fn(const char *fpath, const struct stat *sb, int typeflag) { if (found == 0b111) break; } + /*printf("\nend parsing...\n");*/ fclose(fd); // just add this to the list if (name_buf != NULL && exec_buf != NULL) { + /*printf("gonna add to session list\n");*/ if (used_size >= alloc_size) { alloc_size += bs; sessions = realloc(sessions, alloc_size * unit_size); @@ -128,6 +134,7 @@ struct sessions_list *get_avaliable_sessions() { for (uint i = 0; i < sources_size; i++) { session_type = sources[i].type; + /*printf("recurring into %s\n", sources[i].dir);*/ ftw(sources[i].dir, &fn, 1); } From a32e4a577fa779ba7bc499aa779b7134d9732994 Mon Sep 17 00:00:00 2001 From: javalsai Date: Fri, 26 Jul 2024 16:40:46 +0200 Subject: [PATCH 21/23] feat: add dinit support --- Makefile | 21 +++++++++++++----- README.md | 21 +++++++++++++++--- assets/{ => media}/lidm.gif | Bin assets/{ => media}/lidm.png | Bin assets/services/dinit | 8 +++++++ .../{li.service => services/systemd.service} | 0 src/main.c | 15 +++++++++++-- 7 files changed, 55 insertions(+), 10 deletions(-) rename assets/{ => media}/lidm.gif (100%) rename assets/{ => media}/lidm.png (100%) create mode 100644 assets/services/dinit rename assets/{li.service => services/systemd.service} (100%) diff --git a/Makefile b/Makefile index 7ad642b..1eee88c 100644 --- a/Makefile +++ b/Makefile @@ -27,10 +27,21 @@ clean: # Copy lidm to /usr/bin install: lidm - install -m 755 lidm /usr/bin - if command -v systemctl &> /dev/null; then \ - echo "Systemd exists, copying service file"; \ - cp assets/li.service /etc/systemd/system/; \ + install -m755 ./lidm /usr/bin + install -m755 ./themes/default.ini /etc/lidm.ini + +install-service: + @if command -v systemctl &> /dev/null; then \ + make install-service-systemd; \ + elif command -v dinitctl &> /dev/null; then \ + make install-service-dinit; \ else \ - echo "No systemd"; \ + printf '\x1b[1;31m%s\x1b[0m\n' "Unknown init system, skipping install..."; \ fi + +install-service-systemd: + install -m755 ./assets/services/systemd.service /etc/systemd/system/lidm.service + @printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'systemctl enable lidm'" +install-service-dinit: + install -m755 ./assets/services/dinit /etc/dinit.d/lidm + @printf '\x1b[1m%s\x1b[0m\n\n' " don't forget to run 'dinitctl enable lidm'" diff --git a/README.md b/README.md index 08fc412..c780012 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # LiDM LiDM is a really light display manager made in C, highly customizable and held together by hopes and prayers šŸ™. -![demo image](assets/lidm.gif) +![demo image](assets/media/lidm.gif) > *This is shown as in a terminal emulator, actual linux console doesn't support as much color and decorations.* > *But all colors and strings are fully customizable.* @@ -24,7 +24,6 @@ LiDM is a really light display manager made in C, highly customizable and held t * Long sessions, strings, usernames, passwords... they will just overflow or fuck your terminal, I know it and I don't know if I'll fix it. ## Forget it -* Any kind of arguments. * UTF characters, I'm using `strlen()` and treating characters as per byte basis, UTF-8 chars might work or not actually, might fix it by replacing some `strlen()` with a utflen one. > [!CAUTION] @@ -54,6 +53,8 @@ FYI, this laptop is so bad that I can't even render markdown in reasonable time, * Make (Also optional, but does things atomatically, make sure `gcc` and `mkdir -p` work as expected). # Usage +Regarding arguments: If a single argument is provided (don't even do `--` or standard parsing...), it passes that argument to `chvt` on startup, used (at least) by the dinit service. + On top of pure intuition: * You can change focus of session/user/passwd with up/down arrows. * In case arrow keys do nothing on the focused input (Either is empty text or doesn't have more options), it tries to change session and if there's only one session it changes user. @@ -66,13 +67,27 @@ On top of pure intuition: git clone https://github.com/javalsai/lidm.git cd lidm make # šŸ‘ -sudo make install ``` # Installation * You can put the compiled binary anywhere you want tbh, you can even setuid it if you want to run it with any user, but code's not too safe 😬. * Prepare the [configuration](#configuring). +```sh +# place binary in /usr/bin and copy +# default theme to /etc +make install +``` * Make a service file for this if you want it on launch, just check how ly does it, this works pretty much the same way. +```sh +# automatically detects init system +# and installs service file (for tty7) +make install-service + +# There's manual scripts too: +make install-service-systemd # systemd +make install-service-dinit # dinit +``` + # Disabling other DM's with systemd You may want to disable your current Display Manager for instance: diff --git a/assets/lidm.gif b/assets/media/lidm.gif similarity index 100% rename from assets/lidm.gif rename to assets/media/lidm.gif diff --git a/assets/lidm.png b/assets/media/lidm.png similarity index 100% rename from assets/lidm.png rename to assets/media/lidm.png diff --git a/assets/services/dinit b/assets/services/dinit new file mode 100644 index 0000000..5d6e7d0 --- /dev/null +++ b/assets/services/dinit @@ -0,0 +1,8 @@ +type = process +command = /sbin/agetty tty7 linux-c -n -l /bin/lidm -o 7 +restart = true +depends-on = login.target +termsignal = HUP +smooth-recovery = true +inittab-id = 7 +inittab-line = tty7 diff --git a/assets/li.service b/assets/services/systemd.service similarity index 100% rename from assets/li.service rename to assets/services/systemd.service diff --git a/src/main.c b/src/main.c index 1dfe107..8ed7467 100644 --- a/src/main.c +++ b/src/main.c @@ -9,9 +9,20 @@ #include #include +void chvt(char *arg) { + size_t bsize = snprintf(NULL, 0, "chvt %s", arg) + 1; + char *buf = malloc(bsize); + snprintf(buf, bsize, "chvt %s", arg); + system(buf); + free(buf); +} + int main(int argc, char *argv[]) { - struct config* config = parse_config("/etc/lidm.ini"); - if(config == NULL) { + if (argc == 2) + chvt(argv[1]); + + struct config *config = parse_config("/etc/lidm.ini"); + if (config == NULL) { fprintf(stderr, "error parsing config\n"); return 1; } From 5861b4dc34c12bdfb4f9cb40dd7b5aa0353fe0bb Mon Sep 17 00:00:00 2001 From: javalsai Date: Fri, 26 Jul 2024 17:08:34 +0200 Subject: [PATCH 22/23] =?UTF-8?q?"Mostly=20README=20changes"=20?= =?UTF-8?q?=F0=9F=A4=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c780012..1dda426 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ LiDM is a really light display manager made in C, highly customizable and held t (TODO, VSC(odium) does this automatically, I'm on nvim rn šŸ˜Ž). ## Features -* Builds fast af. +* Builds fast as FUCK. + * 2.830s: laptop, -O3, -j2, `AMD E-450 APU with Radeon(tm) HD Graphics` + * 0.172s: desktop, -O3, -j12, `AMD Ryzen 5 5600G with Radeon Graphics` * Works everywhere you can get gcc to compile. * Fast and possibly efficient. * Fully customizable, from strings, through action keys, to colors (I hope you know ansi escape codes) @@ -139,6 +141,8 @@ Hope you didn't expect actual project recommendations, but these songs are šŸ”„: * "The Neighbourhood - Sweater Weather" * "Cascada - Everytime We Touch" (potentially the sped up versoin if better) * "Mitski - My Love Mine All Mine" +* "Dutch Melrose - RUNRUNRUN" +* "Bring Me The Horizon - Happy Song" Oh, an actual recommendation, if you don't like a element you can change the fg color of it to be the same as the bg. From 9d81c9df8bbc09b535b5d46c832b33dbf73ff5cf Mon Sep 17 00:00:00 2001 From: javalsai Date: Fri, 26 Jul 2024 18:17:17 +0200 Subject: [PATCH 23/23] feat: better handling * setui/setgid/etc errors are recoverable now * fix small print_errno arguments bug * send TERM env var to session (if present) --- src/auth.c | 103 +++++++++++++++++++++++++++++++++++------------------ src/ui.c | 2 +- 2 files changed, 69 insertions(+), 36 deletions(-) diff --git a/src/auth.c b/src/auth.c index e3f5fd1..9ca71b4 100644 --- a/src/auth.c +++ b/src/auth.c @@ -5,12 +5,14 @@ #include #include #include +#include #include #include #include #include #include +#include int pam_conversation(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) { @@ -51,6 +53,11 @@ pam_handle_t *get_pamh(char *user, char *passwd) { } #undef CHECK_PAM_RET +void *shmalloc(size_t size) { + return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, + -1, 0); +} + void moarEnv(char *user, struct session session, struct passwd *pw) { chdir(pw->pw_dir); setenv("HOME", pw->pw_dir, true); @@ -96,45 +103,66 @@ bool launch(char *user, char *passwd, struct session session, return false; } - // point of no return - // TODO: move this to get_pamh, before first setcred, like login does - if (cb != NULL) - cb(); - - if (setgid(pw->pw_gid) == -1) { - perror("setgid"); - exit(EXIT_FAILURE); + bool *reach_session = shmalloc(sizeof(bool)); + if (reach_session == NULL) { + perror("error allocating shared memory"); + return false; } - if (initgroups(user, pw->pw_gid) == -1) { - perror("init groups"); - exit(EXIT_FAILURE); - } - - char **envlist = pam_getenvlist(pamh); - if (envlist == NULL) { - perror("pam_getenvlist"); - exit(EXIT_FAILURE); - } - - // TODO: chown stdin to user - - if (setuid(pw->pw_uid) == -1) { - perror("setuid"); - exit(EXIT_FAILURE); - } - - system("clear"); - printf("\x1b[0m\x1b[H"); - for (uint i = 0; envlist[i] != NULL; i++) { - putenv(envlist[i]); - } - // NOTE: path hotfix - putenv("PATH=/bin:/usr/bin"); - free(envlist); - moarEnv(user, session, pw); + *reach_session = false; uint pid = fork(); if (pid == 0) { // child + char *TERM = NULL; + char *_GETTERM = getenv("TERM"); + if (_GETTERM != NULL) + strcln(&TERM, _GETTERM); + if (clearenv() != 0) { + print_errno("clearenv"); + _exit(EXIT_FAILURE); + } + + char **envlist = pam_getenvlist(pamh); + if (envlist == NULL) { + print_errno("pam_getenvlist"); + _exit(EXIT_FAILURE); + } + for (uint i = 0; envlist[i] != NULL; i++) { + putenv(envlist[i]); + } + // FIXME: path hotfix + putenv("PATH=/bin:/usr/bin"); + if (TERM != NULL) { + setenv("TERM", TERM, true); + free(TERM); + } + + free(envlist); + moarEnv(user, session, pw); + + // TODO: chown stdin to user + // does it inherit stdin from parent and + // does parent need to reclaim it after + // this dies? + + if (setgid(pw->pw_gid) == -1) { + print_errno("setgid"); + _exit(EXIT_FAILURE); + } + if (initgroups(user, pw->pw_gid) == -1) { + print_errno("initgroups"); + _exit(EXIT_FAILURE); + } + + if (setuid(pw->pw_uid) == -1) { + perror("setuid"); + _exit(EXIT_FAILURE); + } + + if (cb != NULL) + cb(); + + *reach_session = true; + // TODO: these will be different due to TryExec // and, Exec/TryExec might contain spaces as args if (session.type == SHELL) { @@ -152,6 +180,11 @@ bool launch(char *user, char *passwd, struct session session, pam_setcred(pamh, PAM_DELETE_CRED); pam_close_session(pamh, 0); pam_end(pamh, PAM_SUCCESS); + + if (*reach_session == false) { + return false; + } else + exit(0); } return true; diff --git a/src/ui.c b/src/ui.c index 6ca03aa..7d66a71 100644 --- a/src/ui.c +++ b/src/ui.c @@ -569,7 +569,7 @@ void print_errno(const char *descr) { origin.x, theme.colors.err, errno, strerror(errno)); else { fprintf(stderr, "\x1b[%d;%dH\x1b[%sm%s(%d): %s", origin.y - 1, origin.x, - descr, theme.colors.err, errno, strerror(errno)); + theme.colors.err, descr, errno, strerror(errno)); } }