From 67c7c45bcdb934b0ea694fb28bfd59f82e3d8d3e Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Thu, 23 Mar 2023 11:31:53 +0100 Subject: [PATCH] Cleanup --- content/insanity.md | 10 +++---- content/rambles/xmonad-prompts.md | 47 ++++++++++++++++++------------- layouts/_default/index.html | 24 +++------------- layouts/shortcodes/about.html | 2 +- themes/vugo | 2 +- 5 files changed, 39 insertions(+), 46 deletions(-) diff --git a/content/insanity.md b/content/insanity.md index 8fbceb9..995f54d 100644 --- a/content/insanity.md +++ b/content/insanity.md @@ -9,11 +9,11 @@ description: "Insanity of the aural variety." The tracks used in this... thing are from the following games: |Track Source | Channel | -|---------------------------------| ---------| -|Don\'t Starve OST - Ragtime | Center | -|Blood - The Chanting track | Center| -|Painkiller - The Carnival level | Left| -|Blood - The Mall/Elevator music | Right| +|---------------------------------|---------| +|Don\'t Starve OST - Ragtime | Center | +|Blood - The Chanting track | Center | +|Painkiller - The Carnival level | Left | +|Blood - The Mall/Elevator music | Right | This is a file dedicated to aural insanity produced every now and then diff --git a/content/rambles/xmonad-prompts.md b/content/rambles/xmonad-prompts.md index 59f9a1b..da9ed84 100644 --- a/content/rambles/xmonad-prompts.md +++ b/content/rambles/xmonad-prompts.md @@ -3,7 +3,7 @@ title: "XMonad Promtps" date: "2023-03-08T14:20:11+01:00" author: "$HUMANOID" tags: ["haskell", "xmonad", "linux"] -description: "There aren't a lot of instructions or explanatiosn on creating XMonad prompts, or at least not within a minute of checking my searx instance." +description: "There aren't a lot of instructions or explanations on creating XMonad prompts, or at least not within a minute of checking my searx instance. This is my attempt at filling that gap." toc: true --- # Introduction @@ -16,7 +16,7 @@ standard XMonad Contrib modules (`XMonad.Prompt.Shell`, `XMonad.Prompt.Ssh` and it came to my universal/external Qutebrowser bookmarks menu and `yt-dlp`-and-`pipe-viewer` wrapper. -This tutorial of sorts with assume _some_ Haskell knowledge or not being afraid +This tutorial-of-sorts will assume _some_ Haskell knowledge or not being afraid of diving straight into how Haskell works. I'm not going into great detail on how everything works here. @@ -34,7 +34,7 @@ choice="$(awk '{print$1}' $bookmarks | sort | dmenu -p "Bookmark:" -l 30)" [ -z $choice ] || qutebrowser "$choice" ``` -Things get interesting at the declaration of the `choice` variable: +Things get interesting at the initialisation of the `choice` variable: 1. It takes the contents of Qutebrowser's bookmarks file 2. It sorts the results of that @@ -44,7 +44,7 @@ Things get interesting at the declaration of the `choice` variable: After this, it checks whether `choice` is empty or not and in case it isn't, opens Qutebrowser with its contents. -{{< start-details summary="Here is an example of how Qutebrowser saves its bookmarks" >}} +Here is an example of how Qutebrowser saves its bookmarks: ``` https://www.alpinelinux.org/ index | Alpine Linux https://www.openbsd.org/ftp.html OpenBSD: Mirrors @@ -53,7 +53,6 @@ https://xxiivv.com/ Echorridoors https://100r.co/site/home.html 100R — home https://solar.lowtechmagazine.com/about.html About this website | LOW←TECH MAGAZINE ``` -{{< end-details >}} ## Implementation @@ -69,18 +68,17 @@ Seems easy enough to implement. ### Parsing the Bookmarks file Lets start off by creating a function that can parse our bookmarks file. Here we -need something to read a file -- in this case a bookmars file -- and return its -contents in the form of a list. So lets create a function that takes an arbitrary -file path and reads its contents, returning them as a list of strings. +need something to read a file -- in this case a bookmarks file -- and return its +contents in the form of a list of strings. ```haskell fileContentList :: FilePath -> IO [String] ``` -This function takes a filepath and returns `IO [String]`. This is to -accommodate that it has to read a file. +This function takes a filepath -- the `Filepath` datatype is an alias for +`String` -- and returns `IO [String]`. -Now for the rest of the function: +Now for the body of the function: ```haskell fileContentList :: FilePath -> IO [String] @@ -90,22 +88,24 @@ fileContentList f = do return . uniqSort . lines $ file ``` -Lets go over what is happening here. +Lets go over what is happening here line by line. -`fileContentList` is a function that takes an argument `f`. +`fileContentList` is a function that takes an argument `f`; then it starts a +`do` block. `do` blocks are used to put multiple functions in sequence in the +scope of a single function without having them interact with eachother. -First, it retrieves the current home directory based on the `$HOME` environment -variable and binds it to `homeDir` using the `getEnv` function from the -`System.Environment` module. `getEnv` returns a string with the contents of the -variable given as its argument. +Within the `do` block, it first retrieves the current home directory based on +the `$HOME` environment variable and binds it to `homeDir` using the `getEnv` +function from the `System.Environment` module. `getEnv` returns a string with +the contents of the variable given as its argument. Next, it retrieves the file contents from `$HOME/path/to/file` using the `readFile`. This path is created by appending `f` to the `homeDir`. Now for the final line. -First it takes the `file` and splits it up into a list of strings based on `\n` -using the `lines` function. +First it takes the `file` and splits it up into a list of strings based on +newlines using the `lines` function. ```haskell lines $ file @@ -115,6 +115,7 @@ Then it pipes the result from that into `uniqSort` from the `XMonad.Prompt` module in order to -- as the name implies -- sort it and get rid of any duplicate items. + ```haskell uniqSort . lines $ file ``` @@ -127,7 +128,15 @@ And the output of that is piped into `return`: This function will allows us to parse any given text file. To parse the Qutebrowser bookmarks file, call it using `.config/qutebrowser/bookmarks/url` +> _Note_: I say "pipe" because the '`.`' function behaves quite similar to +> pipes in POSIX Shell. However, the correct way of referring to what it does +> is composition; it takes two functions and passes the output of the first +> function to the second, thereby creating -- or composing a new function. As +> apposed to how pipes in POSIX Shell work, function composition chains are +> executed from right to left. + ### Creating a Prompt + Lets see if there is anything in the [`XMonad.Prompt`](https://hackage.haskell.org/package/xmonad-contrib-0.17.1/docs/XMonad-Prompt.html) module that looks like it could help us in creating a prompt. diff --git a/layouts/_default/index.html b/layouts/_default/index.html index 27f130d..08def88 100644 --- a/layouts/_default/index.html +++ b/layouts/_default/index.html @@ -1,32 +1,16 @@ {{ define "main" }} {{ .Content -}}
- {{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "rambles") (eq (trim $.Site.Params.contentTypeName " ") "")) }} - {{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "rambles" }} - - {{ $PageContext := . }} - {{ if .IsHome }} - {{ $PageContext = .Site }} - {{ end }} - - {{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }} - - {{ range first 10 .Paginator.Pages }} + {{ $isntDefault := not (or (eq (trim $.Site.Params.contentTypeName " ") "rambles") (eq (trim $.Site.Params.contentTypeName " ") "")) }} {{ $contentTypeName := cond $isntDefault (string $.Site.Params.contentTypeName) "rambles" }} {{ $PageContext := . }} {{ if .IsHome }} {{ $PageContext = .Site }} {{ end }} {{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }} + {{ range first 10 .Paginator.Pages }} - - - - {{ end }} + + {{ end }}

Read more

{{ partial "stickers.html" }} - {{ end }} diff --git a/layouts/shortcodes/about.html b/layouts/shortcodes/about.html index cdf9349..9673efd 100644 --- a/layouts/shortcodes/about.html +++ b/layouts/shortcodes/about.html @@ -2,7 +2,7 @@