Sudoers Permissions as a File

I learned that for granting root permissions to certain programs that it is easer and more constructive to use a separate file. sudo must be told to look in a separate directory in its configuration to be able to do so.

sudo visudo

Likely all distributions have this available and it will be listed at the end:

#includedir /etc/sudoers.d/  

The # is necessary. Also the trailing forward slash is likely necessary (I had to add it); when it wasn’t added, files in /etc/sudoers.d/ would not always get recognized.

Here’s my configuration built from an excellent tutorial in the Ubuntu forums. I usually build these per user naming them user_<USER>.

# Allowed root permissions of programs for user USER

# Aliases
Host_Alias HOST    = aspire
Cmnd_Alias G9LED   = /usr/bin/g9led
Cmnd_Alias IOTOP   = /usr/bin/iotop
Cmnd_Alias PACKER  = /usr/bin/packer
Cmnd_Alias PACMAN  = /usr/bin/pacman
Cmnd_Alias SANDFOX = /usr/bin/sandfox
Cmnd_Alias MYPROGS = G9LED, IOTOP, PACKER, PACMAN, SANDFOX

# Programs allowed for user or computer
todd HOST=(root) NOPASSWD:MYPROGS

The configuration will need to proper-permissions:

sudo chown root:root /etc/sudoers.d/user_<USER>
sudo chmod 0440      /etc/sudoers.d/user_<USER>

Toggle Unity Desktop Effects

Not using desktop effects in Linux helps gaming a good deal, improving frames-per-second and smooth ability. Using Ubuntu’s Unity I’ve noticed gaming gets effected quite a bit. Here’s a script that can toggle them on and off (note that you have to login with desktop effects enabled for this to work). Thanks go to Mossroy and Scott Severance.

Samsung Syncmaster SA350 Monitor: Thoughts and Settings

The Samsung Syncmaster SA350 monitor is a 21.5″ LED monitor with 1920×1080 resolution. I had always wanted an external monitor for my laptop and it has turned out to be really useful. This isn’t a review because I haven’t owned many monitors but I have seen enough monitors to say that this seems to be a pretty good one. I got this three months ago and I can honestly say that I keep appreciating it more over time: good color reproduction, nice brightness, good contrast. The movie high-definition resolution (1920×1080) I was hoping was enough to put applications down side by side and be able to view them and for my needs (basic text editing and internet-browsing) it works:

From my research Samsung is a real good brand to look into when looking at getting monitors. While I am not experienced in using a good different number of monitors, I can say that this monitor I’ve felt comfortable with. From previous experience of using other peoples monitors (schools, friends, and libraries) this by far has been the easiest on the eyes, very little eye-strain even when used for long times. One may comment that with a resolution of 1920×1080 on a 21.5″ monitor that it may not be the best dots-per-inch and they’d be right. It calculates as 102 DPI just above 96 DPI which is still oddly sort of a standard. That said fonts still read easy (take a look a above pic to see what I mean). For some unknown reason though, the Xorg server forced a 96 DPI on it when booting (haven’t been able to figure out why) that required me to find a rather lengthy work-around for.

Settings

As shipped the SamsungSyncmaster SA350’s LED monitor is very bright (almost stinging eyes bright) but isn’t calibrated at all. The settings need a massive adjusted as everything will appear washed out. Having been through photography classes and such I’ve developed a good sense in color balance. Once the settings are done right this LED feels really good (though I still have to get used to the the grey-bare tint LEDs give off). These are the settings:

Picture
Brightness 100
Contrast 24
Sharpness 60
Magic Bright Custom
Magic Angle Off
Coarse (set by auto-discover) 2200
Fine 35
Response Time Normal
HDMI Black Level Normal
Color
Magic Color Off
Red 0
Green 19
Blue 55
Color Tone Custom
Gamma Mode2
Size and Position (necessary to set when using VGA)
H-Position 54
V-Position 40
Image Size Wide

Allotting iotop

Recently, iotop has been moved to being only allowable to be viewed as root. iotop is a great program for measuring disk throughput and I am unable to figure the logic of why it has been moved to root-only. To be able to run iotop as regular user again root permission must be given to the regular user for the program. A good way is to create a sudoers file per-user of allowable programs.

Then iotop can be invoked by (without need of a password):

sudo iotop

Resources

Power Management from the Command Line

To be able to invoke commands like suspend and hibernate from the command line not so long ago required having root privileges or using the desktop environment built-in tools. Now to invoke suspend, hibernate, shutdown, or restart, D-Bus can be invoked as Regular user. I created a script called pwrman to ease the task (requires UPower to be installed).

(I got this idea from a person from the Arch Linux forums. I forgot who you are, so sorry, but thank you.)

Arachnophilia: a Beautiful, Basic, Web Editor

Screenshot from 2014-02-13 06:31:55Update (2014-02-14): Since this post I’ve moved onto Bluefish because it has better support of tables. Bluefish has the ability for pre-defined tags with snippets ability… nice.

I’d just about tossed in the towel on finding an HTML editor that I felt comfortable with when I happened upon this: Arachnophilia; and now I not sure how I could be better off.

Arachnophilia isn’t technically a Linux program, rather it’s a Java program. I’ve avoided using Java programs until now because they ran slowly; however, Java seems to have come a long way from the earlier days and Arachnophilia runs decent, decent enough for me to use on a regular basis.

Arachnophilia is designed to allow direct access to numerous tags. The tags on the two toolbars include the most popular tags and more can be easily added. The library on the left lists a good number more tags. Just about everything is editable in Arachnophilia including the menus. The huge bonus too is that Arachnophilia allows creation of new user-created tags. With this program I’ve been able to create custom tags that I use with my blog.

There is no installing Arachnophilia, just downloading the Arachnophilia Java archive and then directing Java to start it (or if on a Debian system can use the .deb below):

java -jar Arachnophilia.jar

Arachnophilia is simple, plain and enjoyable to use and has easily become my default HTML editor. Thank you Paul Lutus for your work.

Files

gedit to Geany

I’ve decided lately to switch from gedit to Geany as the default editor. I had done this before and really liked it (I didn’t want to set it up again because I didn’t remember all the settings I had changed). Geany is more religious how it handles text and I can’t really define it better than that. All I remember is that there were some odd quirks when I adjusted to gedit like selecting text; also Geany just runs beautiful, real light. Geany is a actually an IDE (an integrated development environment) so it’s more than a text editor but it can be pruned down to feel like a basic text editor and it just runs very very nice.

Settings

To get Geany to behave and feel like gedit a number of setting changes will need to be made. To make changes open up the preferences (Edit > Preferences) and change these settings in the Tabs:

General : Startup

  • Uncheck: Load virtual terminal support

General : Miscellaneous

  • Check: Always wrap search

Interface : Interface

  • Uncheck: Show sidebar
  • DropDwn: Font size for Editor: Same as system

Interface : Toolbar : Customize Toolbar Button

  • Removed: Revert, Close
  • Added: Undo and Redo
  • Removed: Back and Forward Location (Unknown use)
  • Removed: Compile, Execute, and Build
  • Removed: Color Chooser
  • Removed: Goto, Jump to (Using Ctrl + L instead)
  • Removed: Quit

Editor : Features

  • Check: Line Wrapping
  • Uncheck: Code folding (I like to see all the text)
  • Check: Newline strips trailing spaces (I find it hard remembering empty spaces)
  • Set: Line breaking column to 80 (Good for readability, more oft use)

Editor : Indentation

  • Set: Width 2 (Two space tabs break up content well without learing the eye overly)
  • Type: Spaces (Spaces translate look as expected)

Editor : Display

  • Uncheck: Show line numbers (Don’t often need to know)
  • Uncheck: Show markers margin
  • Set: Long line marker > Column to 80
  • Set: Long line marker > Color to #98A8B6

Files

  • Check: Strip trailing spaces and tabs # For a consistent, expected feel
  • Check: Replace tabs by space

After setting these preferences remove the Message Pane by unchecking View > Show Message Window.

Automatic Save

gedit has a useful feature in one of its’ options of being able to autosave files at certain intervals. To get the same functionality in Geany do:

Tools > Plugin Manager

  • Check: Save Actions
  • Select: Preferences
  • Check: Auto Save: Enable & Save all open files
  • Check: Backup Copy: Enable

Geany as Default Text Editor

xdg-mime default geany.desktop $(grep MimeType /usr/share/applications/geany.desktop | sed 's/MimeType=//' | sed 's/;/ /g')

Use Generic Text Editor Icon

Ubuntus’ icon theme has a generic text editor icon that gets tied to gedit. To be able to use it with Geany do:

cp /usr/share/applications/geany.desktop ~/.local/share/applications/
sed -i 's/^Icon=.*$/Icon=accessories-text-editor/g' ~/.local/share/applications/geany.desktop
sed -i 's/=Geany/=Text Editor/g' ~/.local/share/applications/geany.desktop
nautilus ~/.local/share/applications/

From nautilus, drag geany.desktop to Launcher

Change Colorscheme

Note: To get colorscheme support to work properly it may be necessary to install the latest version of Geany. If I understand correctly this is part the development (a.k.a. master?)‘ branch. Nightly builds for various systems can be found here.

Colorscheme support in Geany is still rudimentary. Thankfully a fellow named codebrain has done a lot of the work and it is easy. Much appreciate the work codebrain, thank you.

gny_cnf_dir=~/.config/geany															# define config dir
[ ! -d $gny_cnf_dir ] && mkdir $gny_cnf_dir             # create config dir
cd $gny_cnf_dir
[ -d $gny_cnf_dir/colorschemes ] && \
mv $gny_cnf_dir/colorschemes{,_$(date +%F-%R)}          # backup original
git clone git://github.com/codebrainz/geany-themes.git  # get repository
mv $gny_cnf_dir/geany-themes $gny_cdf_dir/colorschemes

To Do

  • Remove line wrap arrows? – I learned how to do this before from a developer and lost it; afraid to ask again.

bashrc

The ~/.bashrc is a the bash shells’ setting file. The ~/.bashrc can also be used to specify other bash shell related items like abbreviating commands and creating shortcuts. Here is my ~/.bashrc, all bells, no whistles.

The ABC’s of creating MP3s



Being content with GUI ripping software was something that didn’t happen to me using Linux. I had expected my music player software to handle `the task but I can’t remember any that did (not remembering to me is the same as working poorly I’m discovering). As for stand-alone rippers I haven’t heard any that were notable. Because I’m a big fan of software being efficient and to the point (do one thing and do it well) I was a bit nonplussed when I began wondering how I was going to import my CDs to MP3s. A good number of tasks that I had regularly done through the GUI, I discovered are better done through the command line and though I haven’t tested every MP3-related application this looks like it may be true for them as well. Here’s a complete-ish guide to ripping, organizing, repairing, and volume normalizing an audio collection well, done mostly through the CLI.

Rip

RipIT is program that can do just about anything that a GUI version to do. It’s default options will be good enough for most cases (running ripit is all that is needed). Having a greater amount of control however can save time in the end. A wrapper script can be created to help with this:

The ripcd script below defines:

  • The ripping preset (extreme here because storage space isn’t an issue).
  • The directory creation template. RipIT goes online and gets the album tag information which can be used organize directories by tag (here the common "$artist/$album" is used”).
  • Looping (prompts when for new CD when ripping is done)
  • Ripping priority so RipIT plays nice with other programs.
  • Query the MusicBrainz music database instead as it is usually more accurate (editor approval required).
  • The Audio sub-directory to rip it (my Audio directory is divided as such: # ls ~/Audio/ Audiobooks Music Others Podcasts)

Normalize

Normalizing audio means to adjust the volume of audio files to a standard level. This is often a good idea as average volumes levels per album usually differ to some degree. A great program called mp3gain can do this easily. I created a script for this that first normalizes by type (either Music collection, or Audiobook collection… since there are usually differing recording standards for each), then normalize relative to other albums in that catagory. Here’s the script:

Repair

Lame is used by RipIT for encoding of the audio files and does a very good job of it, occasionally though I’ve found it to make a mistake. For these MP3s, previous rips, and for MP3s that have been previously downloaded it is good idea to check them and see if they are in good shape. An excellent tool called MP3 Diags can test MP3s and fix common problems. Repairing MP3s I’ve discovered makes inter-operability between different players play nice. MP3 Diags also includes a very nice (though basic) tag editor.

Bash Script Templates

The basic and expanded templates I use to begin most of my bash scripts:

template-basic

template

Syntax Highlighting in Blog Posts with Vim

Update: Reader Elder Marco has pointed out that WordPress.com does have support for syntax highlighting of source code built-in (which I had never heard of before) that might be a preferred alternative for some. An example of both is below.

Vim is a great all-around editor, it also does very good at syntax highlighting. With the plugin “TOhtml” included with Vim it’s easy to put that highlighting into a blog post. I created a blogscrpt bash script that when run on another script will produce a file defining the syntax highlighting in HTML code. From there it can be pasted into the blog post.

blogscrpt syntax highlighting:

#!/bin/bash
# Create HTML code from Vim syntax highlighting (for use in coloring scripts)

filename=$@
background=light
colorscheme=beauty256
scrpt=${0##*/}  # filename of script

# Display usage if no parameters given
if [[ -z "$@" ]]; then
  echo " $scrpt <filename> - create HTML code from Vim syntax highlighting"
  exit
fi

# Syntax highlighting to HTML export
vim -f  +"syntax on"                  \
        +"set background=$background" \
        +"colorscheme $colorscheme"   \
        +"let html_use_css = 0"       \
        +"let html_no_pre = 1"        \
        +"let html_number_lines = 0"  \
        +"TOhtml"                     \
        +"x"                          \
        +"q" $filename

# Clean up HTML code
tidy -utf8 -f /dev/null --wrap -m $filename.html

# Delete the HTML meta page information.
sed -i '1,/body bgcolor=/d' $filename.html

# Remove line breaks (needed for some things like blog posts)
sed -i 's|<br>||g' $filename.html

# Remove the closing HTML tags
sed -i 's~</body[^>]*>~~g' $filename.html
sed -i 's~</html[^>]*>~~g' $filename.html

# Add preformatting tabs <pre> and </pre>
#sed -i '1 i <pre>' $filename.html
#sed -i '$ a </pre>' $filename.html

# Remove trailing blank lines
while [ "$(tail -n 1 $filename.html)" == "\n" ]; do
  sed -i '$d' $filename.html
done

# Delete newline of last <font> line for better formatting
sed -i ':a;N;$!ba;s/\(.*\)\n/\1/' $filename.html
sed -i ':a;N;$!ba;s/\(.*\)\n/\1/' $filename.html

# Delete final newline
perl -i -e 'local $/; $_ = <>; s/\n$//; print' $filename.html

WordPress built-in syntax highlight support example:

#!/bin/bash
# Create HTML code from Vim syntax highlighting (for use in coloring scripts)

filename=$@
background=light
colorscheme=beauty256
scrpt=${0##*/}  # filename of script

# Display usage if no parameters given
if [[ -z "$@" ]]; then
  echo " $scrpt <filename> - create HTML code from Vim syntax highlighting"
  exit
fi

# Syntax highlighting to HTML export
vim -f  +"syntax on"                  \
        +"set background=$background" \
        +"colorscheme $colorscheme"   \
        +"let html_use_css = 0"       \
        +"let html_no_pre = 1"        \
        +"let html_number_lines = 0"  \
        +"TOhtml"                     \
        +"x"                          \
        +"q" $filename

# Clean up HTML code
tidy -utf8 -f /dev/null --wrap -m $filename.html

# Delete the HTML meta page information.
sed -i '1,/body bgcolor=/d' $filename.html

# Remove line breaks (needed for some things like blog posts)
sed -i 's|<br>||g' $filename.html

# Remove the closing HTML tags
sed -i 's~</body[^>]*>~~g' $filename.html
sed -i 's~</html[^>]*>~~g' $filename.html

# Add preformatting tabs <pre> and </pre>
#sed -i '1 i <pre>' $filename.html
#sed -i '$ a </pre>' $filename.html

# Remove trailing blank lines
while [ "$(tail -n 1 $filename.html)" == "\n" ]; do
  sed -i '$d' $filename.html
done

# Delete newline of last <font> line for better formatting
sed -i ':a;N;$!ba;s/\(.*\)\n/\1/' $filename.html
sed -i ':a;N;$!ba;s/\(.*\)\n/\1/' $filename.html

# Delete final newline
perl -i -e 'local $/; $_ = <>; s/\n$//; print' $filename.html
Follow

Get every new post delivered to your Inbox.

Join 52 other followers