Host ID: 215
A dork that likes Minecraft, web development, and coffee. Not in that order.
Basic bash prompt information
- Variables and files
.bashrc: the RC file where all of this stuff can be set
PS1: main prompt variable
PS2: continuation prompt
PROMPT_COMMAND: a bash function name, run every time prompt is displayed
- Uses escape sequences
- There are problems with prompts and escape sequences
- Multiple escaping
- String interpretation and variable expansion
- tput to the rescue!
- Takes away the need for complex escape codes
- Must run
tput initat the beginning of your
- TL;DR: Use tput for color strings, add them at the last possible moment, with brackets and backslashes
- Embedding bash scripts
- Single quotes are king
- Will be run every time PS1 is evaluated
- Otherwise, only run at time of assignment
Layout of my prompt
- Two lines
- Information/status line
- Prompt line
- Status line
- Starts with current username
- Changes color when user has mail
- Next is the hostname (truncated)
- Separated by an @ symbol, like an email address
- Changes color when the system is in need of a reboot
- Checks for /run/reboot_required
- Current directory
- Separated from previous items by a pipe
- Truncated with a tilde if user's home is in the path
- Prepended with a number indicating the directory stack, if present
- Appended with the git (±) symbol if we're in a git branch, followed by the name of the branch
- Prompt line
- A blue » character
- Prepended with the number of background processes spawned from this terminal
Link to Git Repository
Editor's Note: added 2017-08-05
Hello, this is Windigo, and Welcome to the another episode of apt spelunking! If you missed the first episode, then you probably missed the second episode as well. I assure you, they were fantastic; no need to go back and check.
This series (and yes, it’s official now) is about finding uncommon packages that are buried in the Debian repos. It could very well be about finding packages in other repos, but no Arch, Fedora, Ubuntu or OpenSUSE users are smart or handsome enough to contribute an episode.
In no particular order, here are a few more packages I’ve discovered.
nodm is a very small, very specific utility that is used to start an X session automatically.
On Debian, you configure nodm with the configuration file located at /etc/defaults/nodm. You can specify whether or not nodm is enabled, which user to run as, and what x session to run.
While hugely insecure, nodm is a great way to avoid the hassle of a full display manager like gdm or lightdm. It’s extremely lightweight, which is perfect for my Mini 9, and kicks things right into my custom i3 session.
cmus is a very comprehensive, console-based music player. cmus stands for “C* music player“.
I received cmus as a recommendation from chalkahlom (Gavin) while looking for a media player suitable for the Mini 9. It is a very light application (1.5M uncompressed), which suited my needs well.
The interface of cmus is slightly strange, and may take some getting used to. It is broken up into seven “views”, which can be accessed using the number keys. The views are “Library”, “Sorted Library”, “Playlist”, “Play Queue”, “Browser”, “Filters”, and “Settings”.
To be honest, I still haven’t given cmus a fair shake. It seems like an excellent music player, but I’m still unable to break away from the familiarity of audacious. I’m once again reaffirming my commitment to trying cmus out; it seems like a really good player, if given the time of day.
Pulseaudio comes with a selection of very handy command-line utilities that can be used to play and record audio in various formats. The one I’d like to discuss is “parecord”.
Ordinarily, I do all of my podcast recording with the arecord utility, which talks directly to ALSA. Last time I tried this, it very badly broke audacity when I tried to import the audio. I sounded like a chipmunk, and then audacity crashed.
parecord is a nice alternative to arecord, because it also does encoding on the fly. There may be an ALSA equivalent that also encodes your audio as you’re recording, but I don’t know about it. At best, you’d have to pipe the output of arecord to avconv or a similar utility.
Using parecord, I can specify the file format using the
--file-formatflag, and record directly to FLAC, which is what HPR prefers. Other formats are available, but I think FLAC is a good balance of quality and compression.
If you prefer the raw recording style of arecord, there is a utility called parec which will record raw audio data, but it’s a bit outside of the scope of this podcast. Also, I don’t really know much about it.
I hope someone can find some use in the applications I’ve mentioned here. If you have some other packages that you find indispensable and/or useful, I’d love to hear about them in your very own episode.
If you should happen to find me on the road, don’t kill me! I’m an atheist!
Also, this will be the contents of my bag:
- Stainless steel coffee mug, Stewarts-branded
- Stanley stainless steel thermos
- Kleen kanteen wide, 40oz stainless steel water bottle
- 1½-foot micro USB cable
- Ethernet cable (currently retractable)
- Sony headphones
- Handful of SD and USB storage, including 64GB primary on keychain
- Maglite AA-powered flashlight
- Ballpoint pen
- Lunch, usually in a mason jar or metal box
- If it’s Wednesday or Thursday, my backup drive
- Dell Mini 9 with AC adapter
- If I’m walking to the Tech Center, a ZaReason Verix laptop with AC adapter
Welcome to the another episode of apt spelunking! If you missed the first episode, I should explain. Apt spelunking is the act of aimlessly searching through your distribution's software repositories, and picking out the gems that you find. I call it apt spelunking because I use Debian, which uses the apt packaging format.
Let's jump into the first package: tvtime.
The package tvtime is a simple one, but it does what it does very well. tvtime interfaces with a TV tuner - specialized hardware that allows your computer to process analog television signals, via coaxial or RCA video cables. If you have this hardware, usually an expansion card or USB peripheral, tvtime allows you to use your computer as an analog television.
tvtime binds to the card of your choosing, allows you to switch between NTSC and PAL modes (NTSC is what I use, that being the American standard), and shows you a wonderfully grainy video. It has filters that can help smooth out the image a bit, but it's still an analog video.
tvtime is video only, so you need to use something else to handle the audio of whatever you are hooking up. Often this is done by the hardware tv tuner somehow; my PCI card tuner has a 3.5mm jack that offloads any sound received over the coaxial wire, and I patch that into my sound card. RCA cables have separate wires for audio, and I plug those into my sound card via a converter cable.
I have used tvtime to hook up videogame consoles, VCRs, and older computers like the TRS-80. It's helped me to defeat Eternal Darkness, an old GameCube game that is still worth a look, and it's allowed me to digitize old VHS tapes we have lying around. More on that in another episode.
It is a fantastic alternative to keeping an older analog TV around. If you have older equipment that needs to dump analog video somewhere, tvtime and a hardware tuner makes for a great setup.
This absurdly spelled program is incredibly good at what it does. Phatch, some sort of unholy combination of "photo" and "batch", is a GUI interface for assembling chains of actions to manipulate image files.
I use this program for web development to save time when creating static photo galleries or other types of images with similar constraints.
To use phatch, you assemble a set of operations (phatch refers to these as "actions") in an ordered "action list". I'll use my gallery thumbnail action list as an example.
There are only two actions in my thumbnail action list: "fit", and "save". Each action has a set of predefined parameters and options that let you tweak what happens to your files. The "fit" action resizes an image without goofing up the aspect ratio. You give it a box to fit the image in, and it fits it fully into that box and cuts off any extra edges. The most important parameters for this action are canvas width, and canvas height - which tells phatch how big the box is. The save action has parameters that let you set which image format to use, which folder to save to, and even what to name the file. For my thumbnails, I have it use the original filename, and append a "_t".
Once you have your action list together, you can tell phatch to run on an entire directory and include or exclude different file types.
There is much, much more to phatch than just resizing images. Sounds like another episode idea… anyhow, moving on!
I left xstarfish until the end, because it's so much fun and so very, very weird. xstarfish generates a random, tileable background that can be dumped to a file, or assigned directly to the X display of your choice.
It uses some sort of magic randomsauce to pick a color palette, some patterns, and some other distortions to that you get a brand-new, unique background every time you run it.
It can also be started in daemon mode, with a timer, to automatically change your wallpaper periodically.
There are at least two problems with this.
First of all, let's start with the practical. You can set the size of the image xstarfish generates, by either using the -g flag and manually setting the geometry with a pixel width and/or height, or you can use the -s flag and set a general size like "small", "large", or "full". If you use "full", xstarfish automatically generates a full wallpaper for your display.
Since xstarfish generates randomness (which is often CPU intensive) and uses that to generate random filters (which can be hard on your CPU) and can be set to do it periodically (which, depending on frequency, could keep your CPU busy), this utility can be a resource hog. I have two monitors, each running 1280x1024 resolution, and when I set it to generate a new background every 10 seconds... well, it didn't. It just maxed out one of my CPU cores, and spit out a background every once and a while. Cutting it down to only generate a single monitor-sized image every 60 seconds made things much more reasonable.
The second, more pertinent issue with xstarfish is that it randomly picks colors and patterns. It is exceptionally random about it. Imagine for a moment that you needed to paint a room, and you wanted to pick random colors and patterns for a room in your house. You would begin by blindfolding a friend and pushing them into the paint isle at your nearest hardware store. Whatever three buckets of paint they bump into first, well, that's your color palette. What do you mean you don't like orange, sea foam and gunmetal grey?
Then, you take those paint cans and proceed to tie one to your ceiling fan, one to your eight-year-old child and swing the third around your head at a 35 degree angle. Fairly quickly, you'll have your own xstarfish-inspired decor.
With all of the potentially awful things that can happen, I really do like xstarfish. It's not something I keep running all the time, and a lot of the options remind me of early 90s Encino Man fashion and school photo backdrops with lasers. But sometimes the patterns are actually quite pleasing, and if I keep the tile size small, it reminds me of 90s web design.
That concludes the second installment of apt spelunking. Please don't let me take all the glory; take a tour through your package manager, whatever distro you use, and tell us about some cool stuff you find!
This is a quick summary of my alarm clock system, written in bash and highly unreliable.
My preferred hardware platform is a Dell Mini 9.
My alarm clock is an embarrassing combination of bash scripts and Audacious, my favorite media player. Any media player will do, as long as it's scriptable.
How It Works
There are currently two bash scripts in my crappy alarm setup. One script is called "wakeup" and the other is called "wakeup-at".
wakeup is simply a wrapper that adds some error handling around audacious. It launches audacious if it can't find an instance running already, waits five seconds for it to get itself together, and then causes it to play. It is also currently broken, so the 'launching audacious' part doesn't work. I have to manually start audacious myself. FAILURE.
wakeup script:#!/bin/bash audacious & sleep 5s audacious -p &
You've noticed that the "wakeup" script doesn't actually have any timing involved; If you want to use it as an alarm, you get to combine it with the bash "sleep" command. This is not a failure, this is by design! An example alarm:sleep 8h; wakeup
One problem with this methodology is that it requires math, and is prone to errors. If I'm going to sleep at 10:46:33 PM and need to wake up at 7:00 AM, I need to chain sleep commands together for each unit of time:sleep 7h; sleep 14m; sleep 27s; wakeup
Get some of that math wrong, and you wake up at the wrong time. FAILURE.
"wakeup-at" is a wrapper around "wakeup" that uses the "at" utility to schedule the wakeup script. So, instead of using multiple sleep commands, it accepts any of the time formats that at accepts:wakeup-at 7:00 AM wakeup-at 6:00AM 2018-02-02 wakeup-at teatime
Here is the wakeup-at script:#!/bin/bash ## Make sure we have enough arguments if [ $# -lt 1 ] then echo "Usage: `basename $0` <time>" exit 1 fi echo "$@" ## Add custom time keywords case "$1" in "eternaldarkness") echo wakeup | at 3:33 AM ;; ## Catch-all; send all arguments to at *) echo wakeup | at $@ ;; esac
If you make a syntax error, "at" tells you about it immediately. Its only failings are what it inherits from the original "wakeup" script.
"Apt spelunking" is a silly term I made up for the act of searching through the Debian package repositories with vague terms, and trying out random applications therein.
Today, we will be covering three packages: surf, lightyears, fbterm
Surf is a lightweight, graphical browser. It uses the webkit rendering engine, and is a GTK-based application (not that you can tell). It is extremely spartan. Part of the suckless project, surf takes the Unix philosophy to it's extreme.
Essentially, you only get a single browser window. No tabs, bookmarks, or other interface to speak of. Any navigation is accomplished through links on the page, or some very rudimentary keyboard shortcuts. Ctrl+H goes forward in history, and Ctrl+L goes backwards. If you want to visit a URL, you can either send it as a command-line argument, or use Ctrl+G to bring up a drun-like text input. It is perfect for lightweight system configurations, surf does the bear minimum to qualify as a web browser.
If you're looking for zen simplicity, or want an easy way to embed a web app in its own window without a lot of overhead, surf is an excellent option.
20,000 light years into space bills itself as a "single player real-time strategy game with steampunk sci-fi". In it, you are given a square of alien landscape, dotted with steam vents, and a small settlement at the center. This settlement runs on the steam so abundant on this alien world, and it's your job to keep the steam flowing.
The game consists of building steam nodes, which capture steam from the vents, and connecting them back to your settlement. Of course, you can't simply build a straight pipe back to your settlement; the length of the pipe is taken into account, and the longer the pipe, the harder it is to get steam to travel through it. You can get around this by daisy chaining nodes together in a web, and providing multiple routes back to your settlement. Running a steam-powered base on this alien planet isn't without its share of dangers, however! There are aliens, inclement weather, and seismic instability that can all damage your network of steam pipes and nodes. If your steam pressure falls below a certain threshold, you lose.
This game has an eerie similarity to network engineering, and I've always enjoyed it a lot. It can get very frustrating, though, and the difficulty levels are steep steps. If you're interested in strategy games, I'd highly recommend giving this one a try.
Another in the lightweight category, fbterm is a terminal emulator that's designed to be run with a framebuffer. A framebuffer is a low-level method for displaying text and/or graphics on a monitor, and is often used to run GUI applications without the overhead of an X server.
You can use fbterm to get an antialiased terminal, with freetype font support. That means you can use bitmap and vector fonts, just like most full-featured terminal emulators, without the extra weight of running an X session and window manager.
If you like window managers, you could also use fbterm as a replacement for one of your consoles, using a program called "rungetty". Here's the instructions: http://superuser.com/a/810655/21018 I don't mind having fbterm as a backup terminal, in case I need to debug an X session or my window manager has locked up. Having an option that is more graphically pleasing than a bare getty TTY can be a lifesaver.
As we are all human to some degree, we require sustenance. When on a roadtrip, this can prove to be challenging - but it is also an opportunity to save money and enjoy yourself!Bringing Food --- - Buying all your food on the road is a good way to empty your pockets - Convenience stores do not have your health in mind; their food is generally over-salty or over-sugary - Stopping for snacks can add lots of extra time to a trip - A quick stop at the grocery store before your trip is not a bad idea - Stock up on non-perishable snacks - Nuts and trail mix are a classic for a reason. They're full of protein and fiber, and easy to munch on in a vehicle - Fruit are sweet, healthy, and also usually easy to eat in a vehicle. Apples and grapes are super easy, bananas less so, and oranges are tricky. You can pre-peel fruit to make it more accessible, but it won't last as long. - Water is important. Make sure to have a gallon jug with you, and refill as necessary. I don't mind tap water, but if you're picky, there are water filters designed for camping that are compact and quick. Keep yourself hydrated! - Your options for variety of food increase a lot with a cooler - Things like cheese and sandwich meats should do fine - Make sure to fill it with ice or freezer packs when you set out in the morning, and maybe during the afternoon depending on weather - Check to see if your lodgings have refrigeration; your cooler will be useless if you don't have something more substantial to use in-between legs of your journey. Stopping To Eat --- - Saving money and being efficient is all well and good, but roadtrips are not all about getting from point A to point B. - A great way to experience an area is by ingesting a small part of it - Add an hour or two to your travel time for a meal stop - Pick lunch or dinner - Lunch may suit your timetable better if you are an early riser - Lunch menus often offer slightly less food for a reduced price - Restaurants may be less crowded for lunches - Dinner might be a better choice if you like waking and driving late - Dinner menus are more comprehensive, but often more on the expensive side - Avoid chain restaurants all the time, but especially on a roadtrip - Local restaurants and eateries are usually found in downtown areas, away from highways. They are well worth the diversion. - Different areas have vastly different cuisines, and trying new things can be very rewarding. Crawfish: who knew? - Find something on the menu that you don't recognize, and eat it. - If you are a picky eater, try not to let your preconceptions stop you from trying something. For instance, coconut soup is surprisingly unlike any other coconut dishes that I've had. - Be polite, be patient. Many tourists are rude, and there is a chance that the person helping you gets to deal with those tourists frequently. - Do not be afraid to ask questions. Figure out what you can, but ask for clarification if something on the menu is unusual. - If you have food-based allergies or special dietary requirements, these might not be accommodated in all areas. If you are a vegetarian or vegan, or are allergic to gluten, peanuts, or dairy, your options may change drastically depending on the region you are in. - A little research into local restaurants could help you determine which places you can eat without stopping at each restaurant in town. - Overall, try to enjoy yourself. Roadtrips can be high-stress affairs, and a meal break can do wonders to relieve some of the stress that's built up over the day. Relax, and give yourself plenty of time to eat
I have spent many, many hours in a vehicle driving around. While travelling, I've found a GPS to be one indispensable tool. These are some of the GPS-related tips that I have discovered:
- Having a "navigator" - someone else to help operate the GPS - can be very helpful in stressful driving situations. If you have someone that can help, let them handle GPS programming.
- Know how to operate your GPS. Planning routes are just the beginning; know how to get your GPS to find food and lodging nearby, and how to change a route to avoid trouble (road closures, traffic jams, detours).
- Update your maps! Old map data can drive you into construction zones or route you into congested areas that new map data would have let you avoid.
- Be aware of tolls! The Northeast loves road tolls, and they can quickly add up. My GPS has the option to route around toll roads; so you can use that, or make sure you are prepared for that expense.
- You can also use your GPS as a normal map, except it's a map automatically centered on your exact position. In certain situations, this can be more useful than having your GPS provide you with directions.
- My GPS tells me the local speed limit, in addition to how fast I'm going. This is an excellent way to avoid getting a ticket.
- Mount your GPS somewhere. Looking down into your lap is a good way to find yourself in a gutter.
- GPS are not 100% accurate! Don't believe their lies! If the directions they are giving you sound bogus, use your better judgement.
- BONUS: Cameras! If you want to take pictures while on the road, try leaving your camera set to the "Landscape" macro if you have that option. It will prevent focus issues when taking quick shots. Also, keep your camera easily accessible to avoid extra distraction. If you have a navigator, they might be the best photographers.
The "Sticky Keys" bug causes the Minecraft client to act as if a button hasn't been released when it has - which causes your character, Steve, to suffer some awful consequences as a result (depending on what situation you are in when the bug occurs).
Upgrading the LWJGL libraries/drivers that come with Minecraft usually fixes this bug. To upgrade the drivers, do the following:
- Download an updated version of the LWJGL libraries
- LWJGL 2.8.0 - Not the latest release, but worked great for me
- Copy the following files from
lwjgl-2.8.0/jar/in the zip file you downloaded to
/home/[youruser]/.minecraft/bin/, replacing the existing files there:
- Copy all of the files from
lwjgl-2.8.0/natives/in the zip file you downloaded to
/home/[youruser]/.minecraft/bin/natives/, again replacing the existing files there
If you still encounter issues with the new versions of the libraries, try a newer or older version until you find one that works with your system. 2.8.0 happens to work for my setup (Debian Stable w. Sun Java), but YMMV - your Minecraft may vary.