Fedora + Plank + App launcher - fedora20

This is how I managed to use 'plank' + an applications launcher in Fedora 20. It workds, but is this 'tip' with 'dbus' appropriate and future proof ?
Install 'plank' with: sudo yum install plank; (maybe RPM fusion is needed)
Remove the 'plank' icon with: rm ~/.config/plank/dock1/launchers/plank.dockitem
Link the launcher with: nano ~/.config/plank/dock1/launchers/show-apps.dockitem
And add the next text:
[PlankItemsDockItemPreferences]
Launcher=file:///usr/share/applications/show-apps.desktop
Create the launcher with: sudo nano /usr/share/applications/show-apps.desktop
Add the next text:
[Desktop Entry]
Version=1.0
Type=Application
Name=Show Apps
Comment=Show applications menu
Exec=gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'Main.overview.toggle();Main.overview.viewSelector._showAppsButton.checked = true;';
Icon=view-grid-symbolic
Path=
Terminal=false

Related

How do I alias python2 to python3 in a docker container?

I am trying to set the default python in my docker container to be python3 and have set the aliases in the dockerfile. When I open the .bashrc file, they show up. As far as I can tell, it should work but the default python version is still 2.7. if I run which python, it will still point to usr/bin/python rather than python3. Same with pip. Can anyone tell me what the problem is? Here is the command I'm using to alias:
RUN \
echo 'alias python="/usr/bin/python3"' >> /root/.bashrc && \
echo 'alias pip="/usr/bin/pip3"' >> /root/.bashrc
Does this look right? I am using ubuntu 17.10
You try to create a symlink for python bin
RUN ln -s /usr/bin/python3 /usr/bin/python & \
ln -s /usr/bin/pip3 /usr/bin/pip
other option is use update-alternatives for more visit this site
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3
and another option is trying source the bashrc file after updating
RUN \
echo 'alias python="/usr/bin/python3"' >> /root/.bashrc && \
echo 'alias pip="/usr/bin/pip3"' >> /root/.bashrc && \
source /root/.bashrc
I recommend seeing all options of python images on Docker Hub
Tip: use anaconda or conda for managing your python versions (conda site)
The answer above is great, except it should be as follows:
RUN ln -s /usr/bin/python3 /usr/bin/python && \
ln -s /usr/bin/pip3 /usr/bin/pip
Perhaps they typo-ed by writing ls which just lists the contents of the directory, rather than using ln which actually creates symlinks.

Opening files from Centos command line in Sublime Text on Windows

I am puttying into my Centos 7 terminal on Windows 10. I would like to be able to open and edit the Linux files using sublime text rather than having to edit right in the terminal. Any thoughts on how to do this?
Get a copy of the Windows apps -- "WinSCP" (for SFTP and use as a remote filemanager, etc. and includes putty), and "Notepad Plus Plus" (Notepad++) ... easy way to edit files on remote server. All are free downloads.
I personally like nano, its really easy to use
nano /path/to/file.c
ctrl + x to exit, ctrl+o to output the file with a y/n save prompt
If you want to use sublime, do the following
$> wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
$> echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
$> sudo apt-get update
$> sudo apt-get install sublime-text
Then this line will show you the sublime help options
$> subl -h
Assuming this:
$> subl /path/to/file.txt

Auto start up midori browser is not working on Raspberry pi

I am trying to start browser in Raspberry Pi, on boot. These are the steps I've followed so far:
I have edited the .bashrc file from the root folder using this command:
sudo nano /home/pi/.bashrc
Added the following line at the end the file.
midori -e Fullscreen -a http://www.google.com
I restarted Raspberry Pi.
sudo reboot
It does not open the browser, on boot. How ever if I manually click on Terminal, it opens the browser.
I got a very simple solution of this. At first install midori on your pi.
sudo apt-get install midori
Then add the file that you want to auto start here.
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
For example you want to open google browser after reboot. Add this line to autostart file.
#midori -e Fullscreen -a http://google.com
Save the file and reboot your Pi. Now the google browser will auto start up every time you reboot.
I got the solution .
In new versions it is not supporting in this autostart file
sudo nano /etc/xdg/lxsession/LXDE/autostart
I changed the code to the below autostart file.
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
You can use crontab
sudo crontab -e
And add
#reboot command_you_want_to_run &
I solved using autostart of LXDE-pi and a sh file.
I had to install xautomation for simulate an user input
sudo apt-get install xautomation
In the home of pi I've created a sh file
touch start_browser.sh
I've inserted the following code in the file
#!/bin/sh
# running the browser on the main desktop
sudo -u pi epiphany-browser -a --profile ~/.config http://www.google.com/ --display=:0 &
# waits a few seconds, we wait that the browser has started successfully
sleep 15s;
# xautomation simulates the pressure on the F11 key for activate the browser in full screen mode on the main desktop
xte "key F11" -x:0
I added the executable permission on the sh file with chmod command
sudo chmod 755 start_browser.sh
I've modified the autostart files of LXDE-pi session
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
by adding the following command to run my sh file
#/home/pi/start_browser.sh
Now our browser should be start in full screen mode at each boot
If it does not, check that the Raspberry's configuration had enabled the boot into the desktop environment
sudo raspi-config
Select: 3 Enable Boot to Desktop/Scratch
Select: Desktop Log in as user 'pi' at the graphical desktop
Enjoy
In latest versions of raspberian you have to edit
sudo vi .config/lxsession/LXDE-pi/autostart
for this
#midori -e Fullscreen -a http://google.com
to work..

Adding menu items to GNOME menu or Unity

I want to add a menu item of my application to the GNOME menu. I had created a desktop file for it and placed it in /usr/share/applications, but the menu item is not appearing in the GNOME menu. Below is my desktop file which I created in the name of Aces.desktop...
[Desktop Entry]
Encoding=UTF-8
Version 1.0
Name=Aces
Comment=Compile and Execute C programs
Categories=GNOME;Application;Development;
Exec=/usr/share/Aces/Aces
Icon=/usr/share/Aces/icon.png
Terminal=false
Type=Application
StartupNotify=true
After placing it in /usr/share/applications, I tried restarting the PC and still it did not work.
Any kind of help is appreciatable... :)
Well I just managed to add my program to Debian 9 / Ubuntu latest Unity interface on three steps.
0.- In you application folder locate or create a squared 72x72 or 96x96 or 128x128 or so on icon with .xpm or .png extension.
1.- In you application folder copy from /usr/share/applications/{example}.desktop, rename it to {myapp}.desktop and craft it to meet your application requirements
2.- run this then edit back {myapp}.desktop in case of problems
$ desktop-file-validate {myapp}.desktop
3.-run this to install your launcher into the appropiate directory and bring it lo live
in case of 'just for current user' do:
$ desktop-file-install --dir=/home/{user}/.local/share/applications/ {myapp}.desktop
'for all users' (/usr/share/applications/) do as root:
# desktop-file-install {myapp}.desktop
I've found my silly mistake :) I forgot to give executable privileges to the desktop file. So after you give executable privileges to the desktop file by the command
chmod +x <desktop file path>
place it in
/usr/share/applications /* So the menu option is available to all the user */
or
~/.local/share/applications /* In this case the menu option is available only to that particular user*/
after you apply the executable permission, the desktop file will take the name and icon specified by you, in the .desktop file.
The term "Gnome Menu" can be a bit ambiguous, but I use MATE-Desktop (the Gnome 2 clone), and the easiest way I've found to add an item to the Applications menu (for example) is to right click on "Applications" and click on "Edit Menu". You can get edit the menus, show or hide various sections, and add a new item with the command, description, icon, etc. Note that right-clicking on any sub-menu (like 'Programming') doesn't work -- it has to be the main 'Applications' menu on your gnome panel.
You can use Arronax, if you want to do this quickly.
This answer uses Firefox and CentOS as an example, but these steps should work for any application. The example assumes that you already have GVim installed.
If you don't, simply pick any other menu item that doesn't use hyphens in its title. For example, using chromium-browser.desktop would be bad, while using caja.desktop would be goodness.
1 DOWNLOAD, INSTALL AND TEST FIREFOX FROM MOZILLA SITE
cd /usr/local
sudo wget http://ftp.mozilla.org/pub/firefox/releases/81.0/linux-x86_64/en-US/firefox-81.0.tar.bz2
sudo tar xvjf firefox-81.0.tar.bz2
sudo rm -fr firefox-81.0.tar.bz2
sudo ln -s /usr/local/firefox/firefox /usr/bin/firefox
firefox &
2 FIND AND ‘INSTALL’ FIREFOX ICONS
find /usr/local/firefox -name \*.png
sudo cp -p /usr/local/firefox/browser/chrome/icons/default/default16.png /usr/share/icons/hicolor/16x16/apps/firefox.png
sudo cp -p /usr/local/firefox/browser/chrome/icons/default/default32.png /usr/share/icons/hicolor/32x32/apps/firefox.png
sudo cp -p /usr/local/firefox/browser/chrome/icons/default/default48.png /usr/share/icons/hicolor/48x48/apps/firefox.png
sudo cp -p /usr/local/firefox/browser/chrome/icons/default/default64.png /usr/share/icons/hicolor/64x64/apps/firefox.png
sudo cp -p /usr/local/firefox/browser/chrome/icons/default/default128.png /usr/share/icons/hicolor/128x128/apps/firefox.png
3 ‘CREATE’ A FIREFOX DESKTOP FILE
cd /usr/share/applications
sudo cp -p gvim.desktop firefox.desktop
sudo sed -i "s/Gvim/Firefox/g" firefox.desktop
sudo sed -i "s/GVim/Firefox/g" firefox.desktop
sudo sed -i "s/gvim/firefox/g" firefox.desktop
sudo sed -i "s/Categories=Utility;TextEditor;/Categories=Network;WebBrowser;/g" firefox.desktop

alternatives --config java bash script

I am writing a script that installs java on a remote machine. After i run the .bin file for the JRE, how can i set the alternatives --config java without the user having to input anything.
For instance, when you type in "alternatives --config java" you are prompted to select which java version you would like. Due to the way i installed java ("/usr/sbin/alternatives --install /usr/bin/java java /location/of/jdk1.6/bin/java 2") the #"2" option should always be the java that i want selected.
So, using an ssh command execution, how can i select the second option for java alternatives without the user having to choose the option. I want it fully automated.
This is in a bash script.
Thanks
Below is the code (working correctly now):
#install the jre
sshRetValue=`ssh -p "22" -i $HOME/sshids/idrsa-1.old ${1} " /home/geiser/jms_adapter/jre-6u25-linux-i586.bin "`;
sshRetValue=`echo $?`;
if [ "$sshRetValue" -eq 0 ];then
echo "java jre installed successfully";
#set the alternative and stuff if needed
ssh -p "22" -i $HOME/sshids/idrsa-1.old ${1} " /usr/sbin/alternatives --install /usr/bin/java java /root/jre1.6.0_25/bin/java 2 ";
echo 2 | ssh -p "35903" -i $HOME/sshids/idrsa-1.old ${1} " alternatives --config java ";
else
echo "java jre installation failed";
fi
You can run the alternatives command non-interactively too. Instead of --config, use the --set option to specify the path of the alternative directly.
sudo alternatives --set java /location/of/jdk1.6/bin/java
This worked for me with Java 8:
alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.8.0_60/bin/java 3
alternatives --config java <<< '3'
Generally, you can feed any program that expects something on the standard input like this:
echo -e "line 1\nline 2\nline 3" | program
I did it using this script:
tmp=`mktemp`
echo 2 > $tmp
alternatives --config java < $tmp
rm -f $tmp
The < means that the content of the $tmp file will be passed to the input of the alternatives command.
Edit: You could simply use a single pipe as other suggested:
echo 2 | sudo alternatives --config java
I had couple java versions in my /usr/lib/jvm directory.
My script had to first remove old symlink, create new one and then specify the path of the alternative directly with update-alternatives (i did not manage to make alternatives work without update- prefix) My system - Debian 8.11
My script:
#!/bin/bash
echo "Removing old java 8 symlink.."
sudo unlink /usr/lib/jvm/java
echo "Linking new java.."
sudo ln -s /usr/lib/jvm/new_java /usr/lib/jvm/java
echo "Updating alternatives for java and java compiler"
sudo update-alternatives --set java /usr/lib/jvm/new_java/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/new_java/bin/javac
The documentation says:
If you want to configure non-interactively you can use the --set
option instead (see below).
--set name path
Set the program path as alternative for name. This is
equivalent to --config but is non-interactive and thus
scriptable.
So, to set alacritty as the default terminal, use the following command:
sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator $(which alacritty) 50
sudo update-alternatives --set x-terminal-emulator $(which alacritty)
In your case, use the following command:
sudo alternatives --install /usr/bin/java java $(which java) 70
sudo alternatives --set java $(which java)

Resources