Mark Lodato's blog

Web Name: Mark Lodato's blog

WebSite: http://marklodato.github.io

ID:176014

Keywords:

Mark,Lodato,blog,

Description:

17 Aug 2014 Merging camera and phone photos I just got back from a vacation where I took photos with both mypoint-and-shoot camera (Canon A540) and my Android phone (Moto X). The camerauses the filename format IMG_????.JPG while the phone uses the formatIMG_YYYYMMDD_HHMMSS.jpg. This means that the two sets of photos cannot beeasily viewed as one coherent set. To fix this problem, I used exiftool tobulk rename the camera files to IMG_YYYYMMDD_HHMMSS_????.jpg.$ sudo aptitude install exiftoolsFirst, I had to fix the timestamp on the camera photos since I forgot tochange the timezone on the camera. EXIF timestamps are recorded in local timewith no timezone information, so I had to correct the timestamps by adding, inthis case, 13 hours.$ exiftool '-DateTimeOriginal+=0:0:0 13:0:0' ???_????.???Then, I renamed the files in my desired format, inserting the timestampsbetween the IMG\_ prefix and the ????.JPG suffix. I also converted thesuffix to lowercase to be consistent with the Android photos.$ exiftool '-filename ${FileName;s/_.*//}_${DateTimeOriginal}_${FileName;s/.*_//;tr/A-Z/a-z/}' -d '%Y%m%d_%H%M%S' ???_????.???Finally, I had to manually adjust the .avi filenames since exiftool cannotwrite EXIF data for AVI files, and thus cannot adjust the timestamps in thefirst command. I did this with a simple copy and paste from the corresponding.thm files. 23 Feb 2014 Enabling the "fixed" font family I really love the “fixed” bitmap font family on Linux. It is readable ata much smaller size than any TrueType font I have found. Compare:To enable this font in Xterm, add the following to your ~/.Xresources:XTerm*font: -*-fixed-medium-r-*-*-13-*-*-*-*-60-iso10646-1XTerm*boldFont: -*-fixed-medium-r-*-*-13-*-*-*-*-60-iso10646-1On Ubuntu, all bitmapped fonts are disabled by default in fontconfig, so it isnot possible to use this font in, say, gnome-terminal or xfce4-terminal. Toenable this font, you must do the following, courtesy of cpitchford onUbuntu Forums:$ sudo su$ cat /etc/fonts/conf.avail/69-fixed-bitmaps.conf EOF ?xml version="1.0"? !DOCTYPE fontconfig SYSTEM "fonts.dtd" fontconfig !-- Enabled Fixed bitmap fonts -- selectfont acceptfont pattern patelt name="family" string Fixed /string /patelt /pattern /acceptfont /selectfont /fontconfig $ ln -s ../conf.avail/69-fixed-bitmaps.conf /etc/fonts/conf.d/$ dpkg-reconfigure fontconfig-config$ dpkg-reconfigure fontconfigAnd then restart X. Presto! 31 Oct 2013 Automatically Starting tmux on SSH It’s always a good idea to use screen or tmux when doing anysignificant amount of over SSH in case your connection gets dropped. If youdo this frequently, you might want to have screen or tmux startautomatically so you don’t forget. To do this, append the following to yourssh command, or if you’re using Chrome’s Secure Shell extension, addthe following to the “SSH Arguments” field:-t -- screen -Ror:-t -- /bin/sh -c 'tmux has-session exec tmux attach || exec tmux'Explanation: -t tells SSH to always allocate a pseudo-TTY. Without this, you’ll get anot a terminal error. -- tells SSH that what follows is a command. Without this, you’ll get acryptic ssh_exchange_identification: Connection closed by remote hosterror, at least with Secure Shell. tmux doesn’t have an equivalent to screen’s -R option, so we need to dothis manually. The command is mostly self-explanatory, except: exec replaces the /bin/sh process with tmux so that we don’t have anextra process hanging around. If you don’t care about this, a simple'tmux attach || tmux' will do. 25 Oct 2013 GitHub's Two-Factor Auth and Gnome-Keyring I recently enabled two-factor authentication on GitHub and then ran intoissues when trying to push with a password. I usually push via SSH, which isunaffected by 2FA, but on some machines I don’t bother with that and just typemy password in the rare circumstance that I push from that machine. Sadly,there is no easy way to use 2FA with this method, so you have to jump througha few hoops.First, you need to set up a GitHub Personal Access Token. This is a long,random password that avoids the need for a second factor at login. (Googlecalls this an “Application Specific Password.”) If you use a Personal AccessToken instead of your regular password when prompted by git push, everythingworks fine.However, this creates a second problem: how do you remember that password? Mysolution was to use Gnome Keyring, which recent versions of git support. Itdoes not come pre-compiled, so you have to compile and install it yourself(thanks to James Ward for these instructions):$ sudo apt-get install libgnome-keyring-dev$ cd /usr/share/doc/git/contrib/credential/gnome-keyring$ sudo make$ sudo rm git-credential-gnome-keyring.o$ sudo mv git-credential-gnome-keyring /usr/bin$ git config --global credential.helper gnome-keyringNow, so long as you include your username in the URL, git will save yourpassword in Gnome Keyring. (If you don’t put your username in the URL, gitdoesn’t seem to save the password.) For example:$ git clone https://MarkLodato@github.com/MarkLodato/scriptsThere is one final caveat. If you are connected to your workstation via SSH,you’ll need to set up D-Bus, or else you’ll get Error communicating withgnome-keyring-daemon. The solution is to add the following to your.bashrc or .zshrc file:if [[ -z $DBUS_SESSION_BUS_ADDRESS ]]; then if [[ -f ~/.dbus/session-bus/$(dbus-uuidgen --get)-0 ]]; then source ~/.dbus/session-bus/$(dbus-uuidgen --get)-0 export DBUS_SESSION_BUS_ADDRESSThis tells D-Bus to use the instance that was started on the machine’sgraphical login, and this in turn allows git-credential-gnome-keyring totalk to the main gnome-keyring-daemon instance. In my case, I have alwaysunlocked the keyring graphically when I was sitting at the machine, so I havenot yet run into the issue where I have to unlock the keyring from the commandline.Summary: Compile git-credential-gnome-keyring from/usr/share/doc/git/contrib/credential/ and add it to yourcredential.helper git config. Remember to include username@ in the push URL, or else git won’t saveyour password. 24 Oct 2013 Controlling Linux with a Remote Control I listen to Pandora all the time at home, and I oftenwant to control it without using the keyboard or mouse. So, a few years ago Ibought a USB infrared receiver for $14. Of course, since I use Linux, thehidden cost was hours and hours of time figuring out how to set it up. Inever wrote anything down back then, but since I had to relearn it all lastweekend to make a few changes, now is a good time to document it.This article is written for Ubuntu 13.04, so some things might be differentfor other operating systems. It also assumes you want to use an infraredremote; you could also use a bluetooth remote or some cellphone app, but Idon’t know anything about those.Summary Buy a “USB Media Center IR receiver” (plus a remote if you don’t have one.) If you have an MCE remote, disable the keyboard emulation in X. Run irrecord and follow the instructions to generate a remote definitionfile. Set up /etc/lirc/ to use the new remote definition file. Restart LIRC and test with irw. Either (a) configure /etc/lirc/lircrc, or (b) configure ~/.lircrc andset up irexec to start at session startup.First, you need an IR receiver. The safest bet is to buy a “USB Media CenterIR receiver,” aka an “MCE receiver.” I got the following one for $14,including shipping:Note that IrDA portsfound in older laptops won’t work for this purpose.Choosing a remoteSecond, you need an IR remote. You could use an existing remote if you knowit won’t cause a conflict—say, you no longer use the TV it goes with, or theTV and the computer are in different rooms. Or, you could buy a new remotejust for the computer. But the most likely option is that you have anexisting remote that has a “universal” feature. In that case, all you need todo is configure the universal feature to use some non-existent device. Forexample, if your TV remote can control a DVD player, and you don’t have DVDplayer, configure the remote to control any DVD player listed in the remote’smanual. It doesn’t matter which one—LIRC can (probably) handle any.Configuring X (if you have an MCE remote)If you have a Windows Media Center (MCE) remote (as opposed to, say, a TV orDVD remote), or if you have set up your universal remote to send MCE codes,then X will automatically interpret some buttons as keyboard keys. If this isall you want, then you’re done!Unfortunately, most people will want more than this, in which case thebuilt-in keyboard emulation will just get in the way. So, you need to disableit. If you forget to do so, X will send the keyboard keys in addition towhatever you configure LIRC to do, and it will appear that you’re gettingdouble key presses.First, you need to determine the product name for your IR receiver. To dothis, make sure your IR receiver is plugged in and look through/proc/bus/input/devices to find the name of your device. Here’s the outputon my computer:$ grep '^N:' /proc/bus/input/devicesN: Name="Power Button"N: Name="Power Button"N: Name="Microsoft Comfort Curve Keyboard 2000"N: Name="Microsoft Comfort Curve Keyboard 2000"N: Name="Logitech Unifying Device. Wireless PID:101b"N: Name="Media Center Ed. eHome Infrared Remote Transceiver (1934:5168)"N: Name="MCE IR Keyboard/Mouse (mceusb)"Find the one that sounds like “Media Center … Remote Transceiver.” Then,create the file /usr/share/X11/xorg.conf.d/10-mce-keyboard-disable.conf withthe following contents, replacing the value of MatchProduct with whatevername you found above. (In the old days, we would have added this to/etc/X11/xorg.conf, but now evidently we create these xorg.conf.d files.)# Disable the MCE remote from acting like a keyboard. (We use lirc instead.)Section "InputClass" Identifier "MCE USB Keyboard mimic blacklist" Driver "mceusb" MatchProduct "Media Center Ed. eHome Infrared Remote Transceiver (1934:5168)" Option "Ignore" "on"EndSectionSetting up LIRCLIRC is the program that interprets IR signals. Toinstall it, run:$ sudo apt-get install lirc lirc-xLIRC works in two steps: the lircd program that translates remote signals togeneric “buttons,” and then client programs—notably irexec—translatebuttons to actions.So, three are things you need to do: Create a remote definition file, unless one already exists. Tell lircd to use the proper definition file. Configure irexec.If you’re using a non-MCE receiver, you may also have to spend some timeconfiguring LIRC to use your receiver, but thankfully MCE receivers work outof the box.Training LIRCUnless there already happens to be a file in /usr/share/lirc/remotes/ thatworks with your remote, you are going to have to train LIRC to understand allthe buttons on your remote. (If there is one already, skip to the nextsection.)Make sure that lircd is not already running, and then use the irrecordprogram to create what I am calling a remote definition file. Obviously,replace WHATEVER_YOU_WANT with, well, whatever you want to call your remote.$ sudo service lirc stop$ sudo irrecord --device=/dev/lirc0 /etc/lirc/lircd.WHATEVER_YOU_WANT.confFollow the on-screen instructions, and when it when it asks you to “Pleaseenter the name for the next button,” open up a new terminal window and run$ irrecord --list | lessto find an appropriate name for the button you want to learn. I recommendonly programming four or five buttons for now, and then moving on to the nextsection. I ended up having to delete my config and start over several times,so it’s not worth investing too much time now.Once you have tested your config with irw in the next section and areconfident it is working, you can run the same irrecord command again to addmore buttons. As long as you point it to the same config file, you won’t haveto go through the training step again.Configuring lircd and testing with irwNow we have to tell lircd to use the new definition file. We do this in twoplaces:First, in /etc/lirc/lircd.conf, include your remote definition file. Thiswill be the only command in the file.include "/etc/lirc/lircd.WHATEVER_YOU_WANT.conf"Second, in /etc/lirc/hardware.conf, set REMOTE_LIRCD_CONF to the remotedefinition file. (I don’t think this does anything, but it doesn’t hurt.)REMOTE_LIRCD_CONF="/etc/lirc/lircd.WHATEVER_YOU_WANT.conf"Now, start lircd and test it with irw. Press a few of the buttons youhave trained in the previous section and make sure they show up in irw. Forexample:$ sudo service lirc start$ irw000000037ff07bed 00 KEY_CHANNELUP mce_custom000000037ff07bec 00 KEY_CHANNELDOWN mce_customIf you get one line per press (plus repeated lines if you hold down thebutton), it works! Feel free to go back to the previous section and configuremore buttons.Configuring irexec via lircrcThe last step is to configure irexec, which is the thing that actually doessomething useful when you press a button. You have two choices here:A. Create /etc/lirc/lircrc and have irexec run as root. This has the advantage of starting and stopping irexec automatically whenever you start/stop lircd.B. Create ~/.lircrc and have irexec runs as your user. If you do this, you need to configure your desktop environment to automatically start irexec at the beginning of each session. You will also need to restart irexec every time lircd restarts.Create one of the two files listed above. Thedocumentation ispretty good, but here is my config file for reference:begin button = KEY_VOLUMEUP prog = irexec config = /usr/bin/pactl -- set-sink-volume 0 +2% # vol+ repeat = 1begin button = KEY_VOLUMEDOWN prog = irexec config = /usr/bin/pactl -- set-sink-volume 0 -2% # vol- repeat = 1begin button = KEY_PLAY prog = irexec config = /home/mark/local/bin/pithos-control playbegin button = KEY_PAUSE prog = irexec config = /home/mark/local/bin/pithos-control pausebegin button = KEY_STOP prog = irexec config = /home/mark/local/bin/pithos-control pausebegin button = KEY_FASTFORWARD prog = irexec config = /home/mark/local/bin/pithos-control skipbegin button = KEY_SLEEP prog = irexec config = /usr/bin/xset dpms force off # blank monitorThe file is pretty self-explanatory. Each button is something I defined inmy remote definition file. The pactl program works with PulseAudio, whichis the default audio system on Ubuntu. The pithos-control program isdescribed in the next section. And the xset line turns off my monitor,which I often want to do if I’m listening to music.When you’re done, remember to either sudo service lirc restart if you areusing /etc/lirc/lircrc or irexec -d if you are using ~/.lircrc.Otherwise, nothing will happen when you press a button.Aside: My Pithos control scriptI always use Pithos to play Pandora. Notonly is it way lighter than the bloated web-based one, it is alsocontrollable via D-Bus. Sending D-Bus commands manually is a bit ugly, so Imade a little wrapped calledpithos-control.The main advantage is that it adds discrete play and pause commands, whichPithos lacks.Appendix: (Not) Using ir-keytableWhen I was trying to set up my remote, I found plenty of suggestions on theInternet to use something called ir-keytable instead of, or in conjunctionwith, LIRC. I did use it for a while, but in the end I found that usingstraight LIRC was way better.The main problem was that ir-keytable (by itself) creates virtual keyboardpresses for each button press. If you want to control, say, the volume, youwould configure the “Vol-“ button to send the XF86AudioLowerVolume key. Thissounds fine, but the issue is that, at least in XFCE, the media keys cause theforeground window to lose focus each time they are pressed. So, if I weretyping something and my wife hit the volume button, a few of my keystrokeswould be lost, which was really irritating. It was even worse when I wasplaying a game.I put up with the above for a long time, but the final straw was when I triedto get the xset dpms force off command to work. It was impossible withir-keytable because the virtual keyboard button that I had to map thecommand to would immediately wake the monitor up. This ended up being ablessing in disguise, since it made me realize that I could ditchir-keytable for LIRC.I also found that ir-keytable was less reliable than LIRC. I have no hardevidence of this and I am not inclined to set it up again, but that was myimpression.Update: Ubuntu 17.04 breaks lircMy setup stopped working after upgrading to Ubuntu 17.04. It appears this isa very common problem. When I ran irw it showed nothing, and when I ranmode2 I got:$ mode2 -d /dev/lirc0Using driver devinput on device /dev/lirc0Trying device: /dev/lirc0Using device: /dev/lirc0Running as regular user markPartial read 16 bytes on /dev/lirc0This first step is to change the driver to default in/etc/lirc/lirc_options.conf:driver = default # was devinputAt this point, it seemed like it was working, but in actuality there wasa root irexec running in addition to my session irexec. And this rootirexec would crash the machine when I pressed fast forward! Turning it offfixed the problem.$ sudo systemctl stop irexec.service$ sudo systemctl disable irexec.service

TAGS:Mark Lodato blog 

<<< Thank you for your visit >>>

Websites to related :
My Credit Report Credit Scores

  "A new identity fraud victim every 2 seconds" 2017 Identity Fraud Study, Javelin Strategy Research Don't be the next victim PROTECT YOURSELF Comprehe

Home | Ukrseamen

  Вакансия Salamis Lines LtdНабирает Экипаж на Пассажирское судно SALAMIS FILOXENIA, Флаг Кипр. Кип

【公式】東京ディズニーリゾート・

  現在のパークの楽しみ方【必ずお読みください】エントリー受付、スタンバイパスなど事前準備が必要な施設を来園前にチェック詳しくはこちら健康と安全のための取

高雄醫學大學 醫學研究所 - 首頁

  首頁輪播gim-promo-013.jpghttps://gim.kmu.edu.tw/images/imageshow_home/gim-promo-013.jpggim-promo-012.jpghttps://gim.kmu.edu.tw/images/imageshow_home/g

ShopAlike.nl: Alle kleding- & me

  Jurk godet met bloem okergeel 29,95* Blauwmode.nl :3.95

Omegaletter | Whats this world

  Ye Shall Be As GodsWhen a team hits on a winning tactic, then logic dictates that it should continue to use that tactic as long as it remains effectiv

大波妹影院|美女晃奶视频|大胸女晃

  金8天国 1876 ソフィア 白昼不倫妻 日本男を引き入れアナルも中出しもする美巨乳人妻 VOL2 Sofia 2021-05-09 20:50:23 372 金8天国 1872 ソフィア 白昼不倫妻

CBHS Health Fund - Belong to M

  Lock in great health cover with this limited time offer. Join on both Hospital and Extras and get all waits waived on Extras and your choice of six we

- Zeist Bouwplaten - Import, ver

  Wie zich een beetje verdiept in bouwplaten gaat al gauw verzamelen, handelen, zelfs uitgeven. Ziedaar in ייn zin de geschiedenis van ZEIST BOUWPLATE

UFO-SCIENCE® - Létude scientif

  Afin de ne pas encombrer les publications sur le site, depuis maintenant 2 ans, toutes nos détections sont postées sur Facebook, sur la page du grou

ads

Hot Websites