• Linux
  • May 2024
    M T W T F S S
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Meta

Neofetch to Fastfetch

In the past few days, I’ve seen several articles and videos about the Neofetch reposistory being archived on GitHub. It hadn’t been updated in nearly four years, and the developer has reportly taken up farming. It’s still in most of the distribution repositories, but they’ll likely be dropped as the distributions update their repositories.

One of the recommended replaces I’ve been hearing about is Fastfetch, written in ‘mostly’ C with a jsonc configuration file. I took a look at the Fastfetch GitHub page and it looked pretty intersting with plently of customization options.

I downloaed and installed it. I found one of the preset configurations I liked, and added and removed a few modules from it. I also added the ASCII image that I’ve been usnig in my Neofetch configuration. I found it a bit frustrating to get it to work since I didn’t find the documentation on their GitHub and in the man page very useful. I mostly figured out by studying the presets and through trial and error.

I noticed that the information in the README file didn’t quite match up with what I was what I was experiencing, things like file names and paths for Debian installation, for instance. I also noted thet that README indicated that the current version worked with Debian 11 and newer, and Ubuntu 20.04 and newer. Looking at the Releases page, I saw that starting with version 2.8.2, the Linux binariers are built with glibc 2.35, meaning they no longer supported Debian 11 and Ubuntu 20.04. I figured that the release notes were more likely to be right and went by them. I still have a few macines running Bullseye.

Once I had it up and running on one machine, I wrote an installation script, using another of my installation scripts as a model. Getting the script right was an adventure in iteelf. Several functions and global variables from my sourced function library either didn’t work at all or behaved only. There were also some typos and varibable names that didn’t get renamed, but that’s one of the dangers of cutting and pasting code.

I tested the problem code with other scripts and on the command line, and they seemed to work fine. They just didn’t work with this script. I spent a lot of time watching the debug information as the script ran and what was being display in my terminal

In my function library I have function that takes an array of packages and checks to see if they’re installed. If they are, the function prints the package name and OK, otherwise it installs the package. The function was attempting to install each package, finding that each was was already the latest version.

One of the functions in the script that was giving me trouble was the one that downloaded the confguration and logo files from my Gitea server. To get it to work, I resorted to using hard-coded paths instead of the variables.

On a whim, I looked at the set command at the beginning of the script, set -euo pipefail. I ran the script with various combinations of options to see if one of them was causing my issues. it turns out that -o pipefail was the culprit. Without that option, the package checking function worked as it should. Then I checked the configuration download function with the variables instead of the hard-coded paths, and they worked.

I was using a script format that I use with several other applications that I install and update from their respective GitHub repositories, so I didn’t expect so many porblems. I started off with a script template and copied the applicable code from a similar script. It turns out I had not been using set -o pipefail in those script, so that would have likely caused the same problems in those script.

After struggling for two days, I now have Fastfetch with my configuration installed on all my compatible system, and it looks good. I really liked my Neofetch configuration, but this is good too.

Update on my GitHub Repos

After GitHub changed to using SSH to push commits to repositories a couple of years ago, I tried to get that all set up and, for the life of me, I couldn’t get it to work. I was apparently missing something, so I gave up on it. About a year ago, I set up a local Gitea server on my home network and that’s been working well for me. The biggest disadvantage of that was there was no access to from outside my network. Everything on my Gitea server is primarily for my own use, but I do have some scripts and projects I might want to share. In the meantime, everything I had on GitHub was sitting stagnant and well out of date.

A few days ago, I decided to take another look at my GitHub presense. I successfully set up my SSH public key on GitHub, and after searching online, I found a couple of git commands that got my old repositories talking to GitHub again via SSH. Then I set forth to update the repositories. I archived the homebankarchive and yt-dl-utilities repos since they’re probably not very useful. I’ll probably remove them complete soon. The FnLoC and FnLoC-Win repositories are still current despite not having done any work on them in a few years. There are some features and improvements I’d like to make, but I don’t know how to implement them. My knowledge of C programming has diminished over the years.

Then I began updating the bashscripts repository by importing up-to-date versions of the scripts from my Gitea repo and pushing them up to GitHub. I also removed some scripts that were of dubious interest. In the last few days I’ve been going through my scripts n the Gitea server, and exporting some of them that others might find useful. I’ve been adding new scripts to the repo a couple at a time and updating them as needed.

For those who are interested, here’s my GitHub.

Youtube-DL script

A couple of years ago, I created several scripts to install, remove, and update Youtube-DL and put them up on my GitHub. Well, those scripts are well out of date now and I’m working on regaining access to my respositories. (See my post, GitHub problems | Rick’s Tech Stuff)

Youtube-DL is available in the repositories on most Linux disttributions, but it’s usually several versions behind, so I download it from yt-dl.org. The repro version, at least on my Linux Mint and LMDE system, is usually installed in the /usr/bin/ directory while yt-dl.org recommends installing to /usr/local/bin/ which is usually ahead of /usr/bin/ in the user’s path.

Originally, I had a suite of utility scripts that handled installatinon, removal, and updating youtube-dl. Yesterday, I decided to consoliate them into one script to handle all those tasks using a command-line argument. The script uses the bash getopts builtin to process the arguments. While the script has an update option, I have a an update script that automatically runs every day. Since it runs as an anacron job, I keep a log, and the update script uses a sed file to format the log into an easy to read format.

iru-youtube-dl

GitHub problems

I hadn’t done anything on GitHub in quite a while, since before they required SSH to push commits. Not long ago, I finally got around to setting up my SSH key and changing my repositories, all that stuff their documentation told me to do. Still, I’m not able to push any changes to my remote repositories. I was able to connect to GitHub via SSH, but when I try to push anything from my local reposistories, I get the following error:

$ git push -f origin master
fatal: 'git@github.com/RickRomig/yt-dl-utilities.git' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I know my remote respositories exist. I’ve searched online and I haven’t found anything that resolves the problem. I’m at a loss. Does something need to be changed in my local git configurations? Do I need to delete my repositories, both on GitHub and locally, and start over? Admittedly, I’m not well-versed in Git. I know enough to accomplish basic tasks in managing my own repositories.

I’ve been considering setting up a Gitea server for my scripts, dot-files, and a couple other projects. It would be just on my local network, no public access. Natually, I would be using SSH to push commits and everything, so I’m wondering if I’d be facing similar problems.

BGMMS Script Update

Way back in September, I created a script to check GitHub repositories for the latest version of some utility programs I frequently use. At the time I called it BGMMS. The script has worked quite well, and I’ve made several improvements to it. I used some of the script’s code to modify the program installation scripts to query the appropriate GitHub page and compare the latest available version with what I have installed. Recently, I wrote a new set of scripts to install, update, or remove the programs.

I renamed and modified the script to accommodate a potentiall longer version number and changed the format of the output to three columns. Then I changed the script to highlight the current version number in yellow if an update is available.

Whilst running the script, I noticed that one of the programs showed a release candidate as the latest version and I realized that there are case where I might want to wait until the new release is ready. To handle that situation, I added code to the installation scripts to confirm whether to install the new version.

iur-marktext v0.1.1 (30 Jan 2022)
Installs, updates, or removes the Mark Text markdown editor.
Current version of Mark Text is 0.16.3, updating to 0.17.0-rc.1...
Are you sure you want to install Mark Text 0.17.0-rc.1?
1) Yes
2) No
Choice: 2
Installation of Mark Text 0.17.0-rc.1 canceled.

BGMMS Script

I have a small network of PCs and laptops and there are a handful of utilities that I usually install on nearly every system:

  • Bat – a cat clone that I use to read scripts and source code.
  • Glow – a utility to read markdown files.
  • Micro – a very nice command-line text editor.
  • Marktext – a markdown editor
  • Stacer – a system optimizer and monitoring tool.

All of these have their repositories on GitHub and, in the past, I’ve had to periodically get on GitHub and check for updates. Most of them don’t update very often but, it was inconvenient to have to check that way.

A few weeks ago, I wrote a script to automate the process a bit. It goes to each package’s repositiory on GitHub, downloads the releases page to a temporary file. Then it uses awk to find the most current version and save it to a variable. It then compares that to the installed version and lets me know if there’s an update available.

In my iniitial version of the script, I had a function for each package, and that worked well enough. But, I knew I could improve upon it and I started thinking on it. Other than the package’s URL and the code to obtain the installed version number, the rest of the process was identical.

I combined the five functions into a single funcion to which I passed the package name from an array using a for loop. The function uses a case statment to determine the appropriate URL and obtain the version number of the package. I eliminated about 60 lines of repetitive code.

bgmms v0.3.1 (10 Sep 2021)
Checks for the newest version number of selected utility programs.

Bat
Latest version: 0.18.3    Installed version: 0.18.3
Glow
Latest version: 1.4.1    Installed version: 1.4.1
Micro
Latest version: 2.0.10    Installed version: 2.0.10
Marktext
Latest version: 0.16.3    Installed version: 0.16.3
Stacer
Not installed

I have scripts to install and update these packages and I modified those scripts to query the appropriate GitHub repositories to determine the newest version and to update the package if necessary. It’s so much better than going to GitHub, checking for updates, then passing the new version to the script as an argument.

Mark Text

I had been looking for a good mark down editor, one in which I could open and view mark down files in their intended viewable form without having to see all the mark down code. The other day I found such an editor that seems to be exactly what I’ve been looking for. It’s called Mark Text and more information can be found at: https://github.com/marktext/marktext .

It’s a WYSIWYG mark down editor with a clean and simple interface, light and dark themes, and several editing modes. I’ve been using it for a couple of days and so far, I’m liking it. I’ve been figuring it out as I go and sometimes I find it difficult to correct formatting mistakes without starting the document over.

The editor is available for Mac, Windows, and Linux. For Linux it’s available as an AppImage or a Flatpak. A binary is also available but they warn you that electron dependencies may need to be installed. I installed the Flatpak which meant that I needed to set up Flatpak support on my systems. The GitHub page provides instructions for setting up Flatpak support and FlatHub for many common distributions.

Utility scripts for youtube-dl

Over the long weekend, I revised my scripts for installing, removing, and updating youtube-dl. The scripts had been working but I thought that they could be improved.

The main change to the installation script was to replace the code that created the update script and copied it to one of the /etc/cron directories. I was already using an update script so I decided to just have the installation script insert the update script.

In the removal script, I broke the process down into several functions. One function removes the version installed through the package manager while another function removes the yt-dl.org version. There are also functions to remove configuration files, the update script, and the log file created by the update script.

The scripts have been uploaded to my GitHub repository. I’m planning to create a separate repository for them but I just haven’t gotten around to it yet.

youtube-dl utilities:

  • yt-dl-install – Removes the distibution’s version and installs from https://yt-dl.org
  • yt-dl-remove – Remove all youtube-dl installations, configuration files, update scripts, and logs
  • yt-dl-update – Updates youtube-dl without any log entries
  • z-ytdlupdate – Anacron/cron update script that creates a log file

bat script

One of my favorite utilities is bat, described as a cat clone with wings by its developer David Peter. It’s more than a clone of cat. In addition to displaying files and file concatenation, it supports syntax highlighting, Git integration, shows non-printable characters, and can pipe its own output to less if the output is too large for one screen. It can also display line numbers which is quite useful when reviewing scripts and source code.

You can also configure bat with different themes, languages for syntax highlighting, different pagers (less is the default).

Bat is available from official sources and repositories for Alpine Linux, Arch, Fedora, Gentoo, Void, and FreeBSD. It’s also available for MacOS and Windows. However, for Ubuntu and other Debian-based distributions, it needs to be downloaded from the repository’s release page.

New versions come out several times a year but they don’t seem to be on a regular schedule. I follow the project on my own GitHub page so I usually get an email when a new version is released.

Naturally, I’ve written a script to install and update bat on my my computers. It started out as a simple script that simply downloaded it from the GitHub repository and installed or updated it. When a new update came out recently, I built upon the script and by updating one variable containing the new version number, I can run the script and update to the new version. The scripts compares the installed version with the new version and if it needs updating will check to see if I’ve already downloaded the update or if I haven’t, download it, and install it.

I just finished the current version of the script today and I’m already thinking about another improvement, inputting the new version number from the command line and updating the new version variable. It will be easy to incorporate that into the script so I’ll probably do it soon.

I wrote my HomeBank Archive script to be run at or near the end of the month but sometimes I forget to run it. The first time this happened, I looked at the script and recreated the zip command with the reference date and the formatted file name. It took me a while to figure out how I had constructed the variables (this is why I have scripts). This last month, I forgot again and I decided that it was quite likely that I’d forget again so I wrote a simple script to run the archive after the end of the previous month, manipulating the dates to get the proper dates to archive the right files.

I write scripts to solve problems, even when I cause the problems.

HomeBank Archive Script

I’ve been working on my script to creat monthly archives my HomeBank backup files throughout the month. (See Archive-Bank Update). The script has grown quite a bit from its original incarnation and become a bit more sophisticated and robust. I’ve added checks and streamlined the code. It’s been a good learning experience.

It recently occurred to me that other people who use HomeBank might find this script useful so I renamed it to hb-archive, polished it up, streamlined the code a bit more, and put in a function to display a help page to explain what the script does and give a general idea of how it works. That little page evolved in to a README file.

I had originally intended to include it in my Bash Script repository but I decided that since it is not a short utility script like most of my others, it should have its own repository. This morning, I created a remote repository on GitHub and pushed the script and its documentation.

Before pushing the new, polished version of the script to GitHub, I pushed my earlier versions first, to establish a version history and show its progression. In hindsight, I probably should have done that with my FnLoC project.

If you use HomeBank to manage your personal accounts and budget, you might find this useful. I’m sure the script could be easily adapted to work with other programs that create daily backup files.