Chromium pop up on Raspbian - chromium

I'm running Chromium 16 on a Raspberry Pi 3 with the latest Raspbian. My purpose is to launch a Chromium page in --kiosk mode on start-up.
The Pi will always be shut down by switching the power off, so on start-up Chromium shows the "Chromium didn't shut down properly" pop-up. I need to disable this pop-up. I already looked for a bunch of solutions on the web, especially on this thread: https://superuser.com/questions/873381/how-can-i-disable-the-chromium-didn-t-shut-down-correctly-message-when-my-brow
Sadly, none of these work for me. I also tried to set the permissions for the chromium preferences file to read only, but permissions seem to be restored on boot.
Any ideas?

I was looking for a long time, here is my solution:
#!/bin/bash
#Set CrProfile to the value of your startup profile's config folder
CrProfile="Default"
HomeFolder="/home/myhome"
#Set URL to the URL that you want the browser to start with
URL="http://www.apple.com"
#Delete SingletonLock
rm -f $HomeFolder/.config/chromium/SingletonLock
rm -f $HomeFolder/.cache/chromium
#Clean up the randomly-named file(s)
for i in $HomeFolder/.config/chromium/$CrProfile/.org.chromium.Chromium.*; do
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' $i
sed -i 's/"exit_state": "Crashed"/"exit_state": "Normal"/' $i
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' $i
done
#Clean up Preferences
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' $HomeFolder/.config/chromium/$CrProfile/Preferences
sed -i 's/"exit_state": "Crashed"/"exit_state": "Normal"/' $HomeFolder/.config/chromium/$CrProfile/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' $HomeFolder/.config/chromium/$CrProfile/Preferences
#Clean up Local State
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' $HomeFolder/.config/chromium/"Local State"
/usr/bin/X11/chromium-browser --no-first-run --kiosk $URL

In most recent version (v60 here), I fix this by running with the following argument
chromium-browser --kiosk --app=http://www.example.com

For those arriving here from Google:
The best way to now perform this task, without having to use incognito, is to adjust two settings in the Chromium preferences. They are:
exited_cleanly
exit_type
From what I have gathered from personal tests, just changing the "exited_cleanly" setting may not always work at preventing the Chromium prompt on startup. Other flags such as "-disable-infobars" will also not work.
To adjust these settings, please add the following in your startup file, before launching Chromium (depending on how you have set up Chromium to automatically run in kiosk mode, this file can either be located at "/etc/xdg/lxsession/LXDE-pi/autostart", "/etc/xdg/openbox/autostart", "~/.Xsession", or another file, depending on what you have already installed).
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/Default/Preferences
sed -i ‘s/”exit_type”: “Crashed”/”exit_type”: “Normal”/’ ~/.config/chromium/Default/Preferences
For example, with my setup (using Xsession), the procedure would go as follows:
Enter "sudo ~/.Xsession" into the console
Insert the above 2 lines into the file, before Chromium is run (You should see a line starting with "chromium-browser", so insert them above this)
Press ctrl + X to exit the file
Type "Y"
Press enter
Reboot the machine
Again, the file used to start up Chromium may be located in a different location, depending on how you have setup your pi, but after changing these two settings, Chromium should start up without displaying the crashing prompt.

Related

ssh one shot command gives partial results

I execute a command to grep a long log file on a remote server and the problem is whenever I ssh first and then execute the grep command remotely I get way more matches than if I do it in one shot as follows:
ssh host 'less file | grep something'
I was suspecting some default automatic timeout with the second version so I experimented with those options -o ServerAliveInterval=<seconds> -o ServerAliveCountMax=<int> but to no avail. Any idea what could be the problem?
The problem was related to less. It does not behave well outside of interactive mode. Using cat solved the issue.

How can I raise the limit for open files in Ubuntu 20.04 on WSL2?

My setup looks as follows: Windows 10, Release 1909 (Build 18363.1082), using WSL2 with an Ubuntu 20.04 environment. Everything works nicely most of the time, but there are some issues I cannot manage to solve.
During development using parcel (React bundler), I run into the problem that the bundler apparently opens lots of files at the same time, and at a certain point, I run into the following problem:
EMFILE: too many open files, open '/home/myusername/Projects/some-project-path/node_modules/#material-ui/icons/esm/RoundedCornerRounded.js'
As parcel seemingly does not easily support using something like graceful-fs, I have tried to increase the limit for open files inside the Ubuntu environment. What I have tried so far:
A simple ulimit -n 4096 (which is the highest possible by default), but it's apparently (by far?) not enough
I tried increasing fs.files-max to something really high in /etc/sysctl.conf, but it doesn't seem to have an effect (neither after sysctl -p nor after a restart of wsl)
I also tried increasing fs.inotify.max_user_watches, but that did not seem to have an effect either
Also setting soft and hard limits in /etc/security/limits.conf did not seem to have an effect
I also found information that changing DefaultLimitNOFILE in /etc/systemd/system.conf can have an effect (so I did that as well)
Has anybody manage to solve a similar system on Ubuntu 20.04 on WSL2? This left me pretty stumped, and it prevents me from using parcel inside this environment. That's a real pity, as really everything else is working really fine.
UPDATE
So I have found out that my changes in various places (probably the one in /etc/security/limits.conf) has had some kind of effect. Just not when logging in directly. This illustrates this:
donmartin#SOMEMACHINE:~$ ulimit -Hn
4096
donmartin#SOMEMACHINE:~$ su donmartin
Password:
donmartin#SOMEMACHINE:~$ ulimit -Hn
65536
donmartin#SOMEMACHINE:~$
Which means: If I su to my own user, the ulimit has indeed been raised. But if I log in just as normal using Windows Terminal, this limit is not in effect. Even more puzzled now - BUT - I have a workaround for my problem. Having set my values to 65536, the parcel build now works, running as my own user. Go figure! I still don't quite know which setting was changing the behaviour now - perhaps somebody has more thorough information on how this works and/or how I can make this also the default without having to do a su to get the updated limits.
I had to add the following line to /etc/systemd/user.conf:
DefaultLimitNOFILE=65535
As written in the answer here:
https://superuser.com/questions/1200539/cannot-increase-open-file-limit-past-4096-ubuntu/1200818#1200818?s=1b927bb17396480da98a94cbacf8da62
Also you may need to run this (if working with applications that monitors changes in many files/folders):
sudo sh -c 'sysctl fs.inotify.max_user_watches=524288 && sysctl -p'
Try this:
$ visudo
ADD: user ALL=(ALL) NOPASSWD:ALL
$ vi ~/.profile
ADD: user ALL=(ALL) NOPASSWD:ALL
$ vi /etc/security/limits.conf
ADD: user soft nproc 10000
user hard nproc 10000
user soft nofile 10000
user hard nofile 10000
Temporarily increase the open files hard limit for the session
Run this 3 commands (the first one is optinal), to check current open files limit, switch to admin user, and increase the value.
$ ulimit -n
1024
$ su <user name>
<Enter password>
$ ulimit -n 65535
Check the new limit:
$ ulimit -n
65535
To check all values, run this:
$ ulimit -a

IntelliJ not picking up environment variables when using ZSH?

I am using oh-my-zsh for my terminal. I have set IntelliJ to use /bin/zsh as the shell path. However no environment variable in my .zshrc file ever seems to get picked up. I'm defining environment variables like this (for instance):
export GOOGLE_APPLICATION_CREDENTIALS="$HOME/mailcreds.json"
But if I run:
echo $GOOGLE_APPLICATION_CREDENTIALS
Nothing comes up.
Set environment variables in ~/.profile instead of ~/.bashrc or ~/.zshrc, see this issue for details.
For me, the issue was that I load tmux automatically using .zshrc.
I followed the solution here: https://youtrack.jetbrains.com/articles/IDEA-A-19/Shell-Environment-Loading
Wrapped just the export ZSH_TMUX_AUTOSTART=true like this:
if [ -z "$INTELLIJ_ENVIRONMENT_READER" ]; then
export ZSH_TMUX_AUTOSTART=true
fi
For Ubuntu, I edited my IDE desktop launcher to run zsh with login interactive:
Go to /usr/share/applications (where the desktop entry usually located).
Edit jetbrains-idea.desktop(might be named differently).
Change Exec field to include /bin/zsh -l -i -c "/opt/intellij/bin/idea.sh".
The final result of the file:
[Desktop Entry]
Version=1.0
Type=Application
Name=IntelliJ IDEA Ultimate Edition
Icon=/opt/intellij/bin/idea.svg
Exec=/bin/zsh -l -i -c "/opt/intellij/bin/idea.sh" %f
Comment=Capable and Ergonomic IDE for JVM
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-idea
StartupNotify=true
Shared the same wrong behavior with Intellij in Manjaro (Arch), which uses zsh by default.
The issue comes with Flatpak, switching to Snap or downloading binaries directly from vendor's page got this solved.
Is similar to this issue (PyCharm): https://github.com/flathub/com.jetbrains.IntelliJ-IDEA-Ultimate/issues/23.

iTerm2: quick download over SSH using CMD+click

iTerm2 allows you to click on a link (CMD+click) and open it quickly. However, when working over SSH, this doesn't work. Is it possible to enable this functionality, so that I can CMD+click a file, and it will automatically download into a folder on my local machine?
Thanks!
This is actually possible with Shell Integration installed. Note that Shell Integration will need to be installed on any server that you are ssh'ing into, not just on your local machine. From this link:
iTerm has recently introduced a feature called Shell Integration. Using this feature, we can upload and download files conveniently directly from iTerm 2. Drag a file into the window when pressing Option Key uploads the file to the remote ssh connection. Right-click on a file using ls command will bring up a context list containing downloading the file.
Click “iTerm2->Install Shell Integration” when sshing into the remote server.
Ensure the server has a correct FQDN as hostname and can be connected through this hostname. (You can use hostname -f to check it)
If you’re using private key authentication, then you should have id_rsa in your .ssh directory. However, you should also put id_rsa.pub in your .ssh directory to use this feature.
Sorry for the late answer, but I was just trying to do the same thing and came across your question. Thought I would post my findings once I found a solution.
I've not had much success with ⌘+Clicking to download via SCP in iTerm2 because I have a complex set of rules involving jump hosts in ~/.ssh/config.
But I have found an elegant work around: a shell function which writes to STDOUT to trigger iTerm2 into capturing the output and saving it as a file!
I keep the following snippet (Toolbelt → Snippets) which I execute to define a command download:
alias download="bash <(base64 -d <<<'IyEvYmluL2Jhc2gKaWYgWyAkIyAtbHQgMSBdOyB0aGVuCiAgZWNobyAiVXNhZ2U6ICQwIGZpbGUg
Li4uIgogIGV4aXQgMQpmaQpmb3IgZmlsZW5hbWUgaW4gIiRAIgpkbwogIGlmIFsgISAtciAiJGZp
bGVuYW1lIiBdIDsgdGhlbgogICAgZWNobyBGaWxlICRmaWxlbmFtZSBkb2VzIG5vdCBleGlzdCBv
ciBpcyBub3QgcmVhZGFibGUuCiAgICBjb250aW51ZQogIGZpCgogIGZpbGVuYW1lNjQ9JChlY2hv
IC1uICIkZmlsZW5hbWUiIHwgYmFzZTY0KQogIGZpbGVzaXplPSggJCh3YyAtYyAiJHtmaWxlbmFt
ZX0iKSApCiAgcHJpbnRmICJcMDMzXTEzMzc7RmlsZT1uYW1lPSR7ZmlsZW5hbWU2NH07c2l6ZT0k
e2ZpbGVzaXplWzBdfToiCiAgYmFzZTY0IDwgIiRmaWxlbmFtZSIKICBwcmludGYgJ1xhJwpkb25l
Cg==')"
The base64-encoded string decodes to:
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: $0 file ..."
exit 1
fi
for filename in "$#"
do
if [ ! -r "$filename" ] ; then
echo File $filename does not exist or is not readable.
continue
fi
filename64=$(echo -n "$filename" | base64)
filesize=( $(wc -c "${filename}") )
printf "\033]1337;File=name=${filename64};size=${filesize[0]}:"
base64 < "$filename"
printf '\a'
done
Which relies on iTerm2's download protocol
Sample session showing the notifications from iTerm2:

Is there a way to configure PuTTY or other terminal to flash the taskbar on next output to stdout?

I'm specifically looking for a solution for PuTTY but also interested for other terminal emulators, like Gnome Terminal.
My thought is it would be useful if I start a tar zxvf to be able to set a trigger on the terminal emulator, minimize it, and on next output to stdout/stderr I get a notification in the task bar that the command has finished.
This works for me:
echo -e "\a"
Then update your PuTTY session to use the Visual Bell, and set "Taskbar/caption indication on bell" to Flashing or Steady.
Then run this command after your tar completes:
tar xvzf file ; echo -e "\a"
Here is a screenshot: Save these settings as the default settings and/or the sessions' settings you have