5

I am developing a replacement for the /sbin/init process that will run 1 time and then remove itself from the system. During development I need to be able to do some debugging. I have no SSH (or network, or even systemd for that matter). I cannot change the locale and reboot. I find it hard to believe that the only option is for me to buy a GB keyboard. Currently, this keyboard is connected to the RPi.

Requirements

  1. Type a | character
  2. No changes to the filesystem
  3. Work with a standard US keyboard
  4. Work with the latest Raspbian Lite (unmodified, as distributed)
    • This appears to be an issue with the GB locale

Update

https://github.com/RichardBronosky/pi-init2 now works and is totally awesome!

Raspberry Pi Pre Init

A program which lets you set up a Raspberry Pi solely by writing to the /boot partition (i.e. the one you can write from most computers!).

This allows you to distribute a small .zip file to set up a Raspberry Pi to do anything. You tell the user to unzip it over the top of the Pi's boot partition - the system can set itself up perfectly on the first boot. You no longer have to host entire distrobution images (like RetroPie).

Thanks for the help, everybody!

  • This may help linuxquestions.org/questions/linux-general-1/… – Steve Robillard Mar 20 '18 at 15:47
  • (deleted my comment and added an answer instead) – Doktor J Mar 20 '18 at 20:20
  • 1
    Are you sure you actually have a US keyboard layout? Your self-answer suggests you have a GB layout. – Dmitry Grigoryev Mar 21 '18 at 8:07
  • 1
    @DmitryGrigoryev I don't know what in my answer made you think I have a GB keyboard. I am using a mini keyboard and the physical layout is different than a full sized US keyboard. But the scan codes it outputs for ~ and \ are those of a US keyboard rather than a GB. – Bruno Bronosky Mar 21 '18 at 19:05
  • 1
    @BrunoBronosky: I tried the accepted answer, but I found I have to also press SHIFT to get a pipe symbol. Not sure if my setup here is special in any way, but my keyboard doesn't even have an AltGr key. This issue occurs on a freshly installed current Raspbian Buster with a (standard ?) American (international ?) keyboard. Experience shows that I will run into this issue again and as it took me a little to get that pipe symbol at last, I added the info for everyone with the same issue some time, including myself ;-) Very well possible though that I actually am the one who misunderstands... – ssc May 11 at 7:51
7

| = AltGr + Shift + `~

\ = AltGr + -_

One solution that I've found is to hold the AltGr key and press the `~ key. But I'm not sure if this would work for a normal "right alt" on a US keyboard. According to wikipedia, the answer is: it depends how the US keyboard was made. I happen to be using a CanaKit CK-KB-101 which is identical to this one and it has a key labeled AltGr. I had never heard of the "Alt Graph" key until this post.

Additional Info

The wikipedia article has a LOT of info. But the most important thing to know is that because the RPi is a British invention, the Raspbian OS ships configured for the GB keyboard that looks like this:

GB keyboard

And the US keyboard looks like this:

US keyboard

The immediate reaction of many is that you just have to locate the key with the proper markings. That is NOT the case. Many of the keys send different scancodes. And creating the proper scan codes is the issue.

Bonus

Although I couldn't use it in this case (because I'm bypassing the init/systemd all together), I'm going to link to another Q/A that might help people that get here via Google. How could one automate the raspbian raspi-config setup? In that answer I explain how you can set your locale and keyboard layout non-interactively (though not "without raspi-config").

| improve this answer | |
  • I'm 99.9% sure that "right alt" on a US keyboard is the same scan code as "alt gr" on European keyboards, so it should work fine. – Peter Green Mar 20 '18 at 19:18
  • You may find it useful to know that I wouldn't've made my original comments (the ones you perceived as arrogant) had this part been included in the original question: "the most important thing to know is that because the RPi is a British invention, the Raspbian OS shipping configured for the GB keyboard". (+1 to this answer (and question), btw, now that I understand the situation more clearly.) – mtraceur Mar 21 '18 at 19:29
  • @mtraceur Hey, I get it. Most of the time what people are missing is something obvious and usually the result of laziness. I have found it very useful to target my answers/comments based on the impression I get from viewing their "Network Profile" rather than their reputation on whatever single Stack Exchange site I meet them on. Find it by clicking their name and then "Network Profile" to the far left near the top. For example stackexchange.com/users/40542/bruno-bronosky?tab=reputation shows I don't post to RPi often but I'm no slouch at Linux. – Bruno Bronosky Mar 21 '18 at 19:40
1

Press alt + ~` key next to the number 1 key it types a pipe

| improve this answer | |
  • You may notice that this answer is quite similar to mine ;-) The difference is that (at least for me) your answer doesn't work because it results in me using the Alt key on the left. This only works (again, for me) when I use the Alt key on the right. So, I'm going to call my answer the more complete one as yours is slightly ambiguous. – Bruno Bronosky Mar 21 '18 at 16:26
1

The problem is the Raspberry pi foundation Raspbian image ships configured for a UK keyboard, while you have a US keyboard.

Keyboards do not send characters to the computer, they send "scan codes". This allows the same keyboard to be sold in many different countries with just the printing on the keys being changed.

However there are two different physical layouts, the 104 key US layout and the 105 key layout used for most non-US layouts. So when you go look at a British keyboard layout, find the key normally used to type the backslash and pipe then go looking for the key in the same location on your American keyboard it just doesn't exist.

Fortunately Linux provides* an alternative way to type these characters. In the UK keyboard layout the right hand alt key becomes "Alt Gr" and can be used as a modifier to type additional characters. The pipe can be typed by using altgr in combination with the key that is labeled as ",~" on a US keyboard while the backslash can be typed using altgr in combiantion with the key that is labeled "_-"

* Note: Linux seems to differ from windows in this regard. Windows types a "broken pipe" instead of a regular pipe.

| improve this answer | |
-1

Try holding Alt, press 1, 2, 4 on the Numpad and release Alt again.

| improve this answer | |
  • 1
    When I do that my prompt gets replaced with (arg: 124) and the next character I type after releasing alt get repeated 124 times. – Bruno Bronosky Mar 20 '18 at 16:21
  • Physical Keyboard connected to the RPi, right? Or via SSH? – eltomato Mar 20 '18 at 16:27
  • 1
    This keyboard is connected to the RPi. amazon.com/dp/B00JO80LUI I am running a custom binary in place of init I have no SSH (or network, or even systemd for that matter) – Bruno Bronosky Mar 20 '18 at 16:52
  • Just to be clear, I DID NOT downvote you. I appreciate your attempt to help me and hope that maybe this answer works for others. I think we should only downvote answers that are detrimental. – Bruno Bronosky Mar 21 '18 at 16:11
-1

From the looks of your keyboard, you've got the pipe character right on it, above the Enter key. Pressing Shift+\ should get you what you're looking for. I know the symbol shown on the key is the "broken bar" (¦) but I'm pretty sure it will actually enter the plain old pipe character when you type it if it's a US keyboard and your input method is set to US/QWERTY.

| improve this answer | |
  • +1 I'd bet in the ballpark of 200 USD that this is the answer in this case, and I'd further bet about 100 USD that on any "US" keyboard on any sensible system, the symbol labeled "broken bar" produces the regular ASCII |. I suspect the only reason it's glyph is the broken bar is because that was a legitimate alternative rendering of the bar/pipe historically, presumably intended to reduce ambiguity with lowercase l (L) and upper-case I (i) in fonts misguided enough to introduce such an ambiguity in the first place. – mtraceur Mar 20 '18 at 20:31
  • (For anyone intending to cheekily ask about actually cashing in on my "I'd bet" statements above: let's make sure we define "sensible system" and "'US' keyboard" so there's no loopholes and get some notaries for third party external validation, and I'd genuinely be happy to.) – mtraceur Mar 20 '18 at 20:34
  • @DoktorJ The issue here is that Raspbian defaults to a British keyboard layout, and the OP states that he can't change the locale to a US one. If the OP was able to change to a US keyboard layout, then this would indeed work. – Aurora0001 Mar 20 '18 at 20:37
  • @DoktorJ you are WAY OFF. I don't need visual assistance finding the key. I have indeed tried every key with and without Shift. This is a well documented issue. Unfortunately the True Fix™ of changing the locale is not an option when you are kernel hacking as I am. Thanks for trying. I'd suggest less hubris in the future. I mean no disrespect. 💙 – Bruno Bronosky Mar 21 '18 at 16:20
  • 1
    @mtraceur I'd say your comments "come off as coming from a place of arrogance / hubris" because you express hyperbolic certainty about something in which you are wrong. If there was a real bet here, you lost the money. Raspbian by default comes configured for a UK keyboard, and because of that, using the pipe key on a US keyboard without reconfiguring the locale does not produce a pipe character. Telling someone to use the right key simply does not work. Anyone who's plugged a pi in with a fresh Raspbian install and skipped configuring for a US keyboard has hit this little roadblock. – goldilocks Mar 22 '18 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.