Tuesday, June 25, 2019

My own Emacs Reference Sheet

It's my own obligatory Emacs Cheat Sheet.  This is for my own future reference, but here for anyone else that may find it more useful than the multitude of other guides out there.

Modes


  • Emacs works in modes, both major and minor  
  • You can only have one major mode active at a time
  • You can open multiple minor modes
  • Major modes are usually auto-selected based on file type that you opened, but you can manually switch it with M-x <name>
  • Modes usually end in "-mode", e.g., web-mode.el
  • List of modes on Emacswiki
  • More modes can be installed with ELPA / MELPA

Moving Around

  • C-f / M-f ⇒ Forward (char) / Forward (word)
  • C-b / M-b ⇒ Backward (char) / Backward (word)
  • C-p ⇒ Previous (line, i.e., up)
  • C-n ⇒ Next (line, i.e., down)
  • C-v / M-v ⇒ Page down / Page up
  • C-a ⇒ Beginning of line (i.e., "Home" key)
  • C-e ⇒ End of line (i.e., "End" key)

Files

  • C-x C-f ⇒ find (open) file... creates file if it doesn't exist
  • C-x C-s ⇒ Save (current buffer)
  • C-x s ⇒ Save (all buffers)
  • C-x C-c ⇒ Exit w/o saving

Windows

  • C-x 2 ⇒ split screen into 2, horizontally
  • C-x 1 ⇒ close all other windows
  • C-x o ⇒ jump to other window
  • C-x 4 f ⇒ open file into other window (split)

Buffers

  • C-x C-b ⇒ List all buffers
  • C-x b ⇒ Switch to buffer (TAB for auto-complete)
  • C-x k ⇒ Kill (close) buffer (default: current buffer) 

Forays into Emacs, part 1

I've been wanting to learn Emacs for a while now, and over the past few days I've forced myself to really dive into it.  It is overwhelming at first, and I didn't really get into it until I finally figured out how to install the package manager, change the theme, and download a useful package for web development (web-mode.el).

Lessons learned:

  • Take the built-in tutorial, and DO the exercises
  • Memorize ONLY the basic commands, you'll get the rest later
  • Figure out how to use the built-in help
  • Install the package manager ELPA / MELPA 
  • Find a use-case for why you're learning EMACS - mine was web development, and luckily I finally found a major mode that seems to fit the bill: web-mode.el
  • Practice using the new keys for your major / minor mode

Tuesday, March 6, 2018

Xfce volume buttons (keyboard)

I got these fixes from a couple Internet sources.

Step 1: Make sure you have amixer installed (i.e., from apt-get)

Mute Button

  • Applications-->Settings-->Keyboard-->Application Shortcuts (tab)
  • If "XF86AudioMute" isn't already mapped, add this command
    • amixer -D pulse set Master toggle
    • It'll prompt you for the key. Select your mute button

 Volume up / down

  • Applications-->Settings-->Keyboard-->Application Shortcuts (tab)
  • Map these commands to your volume up and down keys:
    • amixer set Master 5%+
    • amixer set Master 5%-
That's it!

Tips: you can try these out in the console to see if they work.  Also man amixer is handy.

Sunday, March 4, 2018

XFCE4 Single Tap, multitouch, and brightness keys

I have an old Macbook Pro circa 2008, and recently I've been running Linux Mint 18.3 with Cinnamon desktop; however, I've been wanting to see what the other environments offer;  I tried a few, and Xfce seemed the cleanest to me.  There were, however, a few quirks that I didn't like:

  1. I couldn't change the brightness with the keys on my MacBook (cinnamon does)
  2. There was no option to enable the tap-to-click in the "Mouse and Touchpad" options, even though I saw some screen shots that showed it was supposed to be there.
Brightness Keys:  you need xfce4-power-manager
$ sudo apt-get install xfce4-power-manager
$ sudo reboot
Power Manager should be under Applications -->Settings
Single-tap / tap-to-click: there's a temporary and long-term fix

Temporary:  use libinput libinput on ArchWiki [this resets every boot, skip to next section for permanent solution]

List your devices so you can get the touchpad's id:

$ xinput list
xinput list

List the touchpad's properties:

$ xinput list-props 12


note: it's already "1" because I turned it on previously

"Tapping Enabled" is 276.  Putting this altogether (turn on tapping):

 $ xinput set-prop 12 276 1

(Again, this resets every reboot)

For a permanent solution, use xorg.conf file

Navigate to (Linux Mint 18 / Ubuntu):
cd /usr/share/X11/xorg.conf.d/

If it doesn't exist, create and open touchpad configuration
$ sudo touch 30-touchpad.conf
$ sudo pico 30-touchpad.conf

Using libinput on ArchWiki as a guide again, add the following:
Section "InputClass"
   Identifier "touchpad"
   Driver "libinput"
   MatchIsTouchpad "on"
   Option "Tapping" "on"
   Option "NaturalScrolling" "true"
   Option "ClickMethod" "clickfinger"
   Option "ScrollMethod" "edge"
EndSection

Save, reboot (or just log out/in).  Done.  Note that this configuration assumes you want a virtual scroll "box" on the right-edge of your touchpad instead of the normal 2-finger scroll (use "twofinger" instead of "edge").

End notes (taken from ArchWiki):
You may define as many sections as you like in a single configuration file. To configure the device of your choice specify a filter by using MatchIsPointer "on", MatchIsKeyboard "on", MatchIsTouchpad "on" or MatchIsTouchscreen "on" and add your desired option. See libinput(4) for more details. Common options include:
  • "Tapping" "on": tapping a.k.a. tap-to-click
  • "ClickMethod" "clickfinger": trackpad no longer has middle and right button areas and instead two-finger click is a context click and three-finger click is a middle click, see the docs.
  • "NaturalScrolling" "true": natural (reverse) scrolling
  • "ScrollMethod" "edge": edge (vertical) scrolling
Bear in mind that some of them may only apply to certain devices.

HTH









Monday, January 15, 2018

Quake2 on Linux by compiling Yamagi Quake

On my previous post, I talked about using game-data-packager to install Quake2... but what if you want to do it from scratch?

This blog post is basically a distillation of the Yamagi Quake Readme.md, but I hope that it'll help.

  1. Download Yamagi Quake2 7.10
  2. Download q2-3.20-x86-full-ctf.exe patch
  3. Use Wine to extract the 3.20 patch to an empty directory, say, "quake2"
  4. Extract Yamagi Quake2 7.10 to the "quake2/" directory (above)
  5. Make a temp directory, say, "yamagi make files"
  6. Go into "yamagi make files" directory
  7. Clone repository:  git clone https://github.com/yquake2/yquake2.git
  8. Install Dependencies:  apt-get install build-essential libgl1-mesa-dev libsdl2-dev libogg-dev libvorbis-dev libopenal-dev zlib1g-dev
  9. Build it: type "make"
  10. Copy everything from the "release" folder into your "quake2" folder (step 3)
  11. Copy "pak0.pak" and "videos/" folder from a full version of the game to "quake2/baseq2" folder
  12. Start fragging:  Type "./quake2" in your quake2 folder
References:
https://www.yamagi.org/quake2/

Quake2 on Linux Mint [Jan 2018]

Background:  I have an early-2008 model Macbook Pro (MPB) and I wasted most of an entire extended weekend trying to put OS X El Capitan on (or something close to it) with little success.  The closest I could get was OS X Mavericks but then I got greedy and tried upgrading to El Capitan again...to no avail.

Fast-forward to this weekend and I decided to give up and just put Linux Mint 18.3 on it.  I've also gotten into a nostalgic period (maybe it's the winter), but I decided to started playing my old FPS games like Quake II and Quake I, and I thought, why don't I do this on my laptop?  It can certainly handle the game.

I'm writing this blog because this is definitely not the 1st time I've installed Quake2 on Linux... in fact, it's like the 1st time every time.

1st (Video):  Make sure you have the nVidia drivers enabled.  These can be found in:
Administration ---> Driver Manager
2nd (Wireless for MBP): I have a MacBook Pro, Early-2008 model, so I needed to enable my wireless drivers... it's a Broadcom (BCM4321), which Linux Mint detected, so I had to just enable this in "Driver Manager" again.  I'm currently just using Ethernet cable because it's faster, but the cable gets in the way.

Quake II

From what I understand (I may be mistaken), Linux Mint ships with the Yamagi Quake engine (search for it), which is what we're going to take advantage of here.

Check out my other post if you want to use Yamagi Quake from scratch


Install game-data-packager:  Get this from
Administration ---> Software Manager ---> Search "quake" ---> Select "Quake 2"
From what I understand, this program makes .deb packages to install the games; however, you'll need a full install of Quake II to access the data.

*game-data-packager will install your games in /usr/share/games/

 Package the game:  This took me some time to figure out.  To make a proper .deb install file, you need to point game-data-packager to a full copy of Quake2.  You have a couple options here:
  1. Use Wine to install Quake2 from Steam (install Windows .exe for Steam) so you can grab the files
  2. Grab your Quake2 folder from another machine
I picked choice 2, but either way you just need the path.  From your home directory (or wherever you want the .deb file to land) type this:
$ game-data-packager quake2 --package quake2-full-data /path/to/quake2
 *Note, if you just want the DEMO (which will auto-download):
$ game-data-packager quake2
Install the .deb file:  I simply double-clicked it in my window manager

Start Fragging:  Either type "quake2" in the console or find it under "Games" in your Start Menu 

End notes:
Yamagi Quake: There are other ways to do this, but I found this the easiest.  If you don't have Yamagi Quake, you can go here:
https://www.yamagi.org/quake2/


Set your screen resolution:  I'm on a MPB, 17" so I had to change the in-game settings for Quake2 to "fullscreen" and "1400x900", as that's my native resolution for this laptop.

Hope this helps.


Saturday, February 18, 2017

Linux Mint 18.1 + PIA + OpenVPN + Network Manager Gnome [works]

I finally got Linux Mint 18.1 to correctly use OpenVPN with Private Internet Access (PIA).

Here's what didn't work:
  • The PIA supplied binary.  It installed fine, but would simply time out on any connection
  • Using command-line openvpn... even the /etc/openvpn solutions wouldn't work.
My biggest problem was this: OpenVPN would connect (sometimes), but there wouldn't be any internet connection.  I saw solutions that played with firewalls and iptables, but my Android worked just fine, and I felt like I shouldn't have to mess with iptables, NAT, etc.

Here's what did work:
  • Use "Preferences --> Network" and NOT "Preferences --> Network Connections" or Network Manager that's accessed via the tray
  • Download the default ovpn files and unzip:  https://www.privateinternetaccess.com/openvpn/openvpn.zip
  • Goto "Preferences --> Network"
  • Click "+"  --> "VPN"  --> "Import from file" --> select your ovpn file (i.e., "US East.ovpn")
  • Under "Gateway" delete the " :1198" (or whatever port is listed)
  • Enter your PIA username  ("Type" should already be "Password")
  • Click "Advanced"
  • Enable "Custom Gateway Port" and enter the port# you deleted from the Gateway name (i.e. 1198)
  • Click "Security" tab
  • Select "AES-128-CBC" (even if it's already listed)
  • Select "SHA-1" (even if it's already listed)
  • Click "OK" to close Advanced screen
  • Click "Save"
  • Now in the "Network" screen (NOT from the tray), select your VPN and turn it on.  It'll probably ask you for your password, and a popup will say you connected successfully.
  • Test your VPN by visiting here: https://www.privateinternetaccess.com/pages/whats-my-ip/
Auto-connect to VPN

I haven't tried this yet, but in the "Preferences --> Network Connections" dialog (i.e., the other one not used above), you select your wifi connection --> "Edit" --> "General" tab.  There's an option there to automatically connect to a specific VPN when you connect to your wifi.


Hope this helps!