Position 2 monitors at login with xrandr - xrandr

I'm running Ubuntu 14.04 LTS trusty on a Dell Dimension M6500 and try to get 2 monitors automatically positionned.
Graphic card: Quadro FX 2800M
NVIDIA Driver Version:331.38
I put the line
xrandr --output DP-0 --left-of LVDS-0
which works as a command line in various files: .profile, .xsession, .xinitrc, /etc/X11/Xsession.d/45custom_xrandr-settings
put a sleep 2 before, tried to launch it via batch
the lines
xrandr -q >> xrandr.log
xrandr --output DP-0 --left-of LVDS-0&
xrandr -q >> xrandr.log
work in the .profile file and show that the re-positionning occured but went back before I can see anything !
Any ideas ?

I know this is a bit old, but I found this post while looking for the solution myself, so I thought I'd help.
Make a script called setup_monitors in /usr/bin/ and do sudo chmod +x /usr/bin/setup_monitors
Add this to setup_monitors
#!/bin/sh
# you might want to uncomment the following line or
# something like it as well
# xrandr --output DP-0 --mode 1920x1080 --noprimary --pos 1920x0
xrandr --output DP-0 --left-of LVDS-0
Then in your /etc/lightdm/lightdm.conf add the following:
display-setup-script=/usr/bin/setup_monitors
Restart your desktop environment (logout/restart computer), and it should work.

Related

qemu-system-x86_64 No bootable device. ARM M2 processor. mit6.858

I'm learning the mit6.858. In Lab1, I need to set up the lab environment on my M2 Mac using qemu (version 7.2.0 installed by homebrew).
I follow the instruction of the lab hints and run the course VM Image with this shell scripts:
#!/bin/bash
if ! command -v qemu-system-x86_64 > /dev/null; then
echo "You do not have QEMU installed."
echo "If you are on a Linux system, install QEMU and try again."
echo "Otherwise, follow the lab instructions for your OS instead of using this script."
exit
fi
# can we use the -nic option?
version=$(qemu-system-x86_64 --version \
| grep 'QEMU emulator version' \
| sed 's/QEMU emulator version \([0-9]\)\.\([0-9]\).*/\1.\2/')
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
net=()
if (( major > 2 || major == 2 && minor >= 12 )); then
net=("-nic" "user,ipv6=off,model=virtio,hostfwd=tcp:127.0.0.1:2222-:2222,hostfwd=tcp:127.0.0.1:8080-:8080,hostfwd=tcp:127.0.0.1:8888-:8888")
else
net=("-netdev" "user,id=n1,ipv6=off,hostfwd=tcp:127.0.0.1:2222-:2222,hostfwd=tcp:127.0.0.1:8080-:8080,hostfwd=tcp:127.0.0.1:8888-:8888" "-device" "virtio-net,netdev=n1")
fi
qemu-system-x86_64 \
-m 2048 \
-nographic -serial mon:stdio \
"$#" \
# -enable-kvm \
"${net[#]}" \
6.858-x86_64-v22.vmdk
But I got this output:
SeaBIOS (version rel-1.16.1-0-g3208b098f51a-prebuilt.qemu.org)
iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+7EFD11A0+7EF311A0 CA00
Booting from Hard Disk...
Boot failed: could not read the boot disk
Booting from Floppy...
Boot failed: could not read the boot disk
Booting from DVD/CD...
Boot failed: Could not read from CDROM (code 0003)
Booting from ROM...
iPXE (PCI 00:03.0) starting execution...ok
iPXE initialising devices...ok
iPXE 1.20.1+ (g4bd0) -- Open Source Network Boot Firmware -- http://ipxe.org
Features: DNS HTTP iSCSI TFTP AoE ELF MBOOT PXE bzImage Menu PXEXT
net0: 52:54:00:12:34:56 using 82540em on 0000:00:03.0 (open)
[Link:up, TX:0 TXE:0 RX:0 RXE:0]
Configuring (net0 52:54:00:12:34:56)...... ok
net0: 10.0.2.15/255.255.255.0 gw 10.0.2.2
Nothing to boot: No such file or directory (http://ipxe.org/2d03e13b)
No more network devices
No bootable device.
When I type ctrlA+X to quit, I got another lines of output.
QEMU: Terminated
./6.858-x86_64-v22.sh: line 30: -nic: command not found
My homebrew installation is correct.
I'd like to know how to start the course VM correctly on M2 mac.
So, at first glance this looked off-topic as not a programming question as such (running Qemu is more of a superuser.com or serverfault.com question, or perhaps apple.stackexchange.com as we're talking about running Qemu on macOS), but looking more closely, your problem appears to be a bash scripting one, which makes it on topic again!
The clues
One thing you don't explicitly mention in your question is that you modified the script, attempting to comment out this line:
# -enable-kvm \
(The reason to remove that flag is because kvm is not available on macOS hosts, and the alternative, hvf, is not available when using binary translation to run an x86-64 VM on an arm64 host CPU.)
Another clue to the problem is this error:
./6.858-x86_64-v22.sh: line 30: -nic: command not found
What's happened here is that the backslashes (\) at the end of each of these lines in the original script turn the multi-line block into a single line:
qemu-system-x86_64 \
-m 2048 \
-nographic -serial mon:stdio \
"$#" \
-enable-kvm \
"${net[#]}" \
6.858-x86_64-v22.vmdk
Unfortunately, when commenting a line with #, bash ignores any backslash at the end of the line - this interrupts and splits the multi-line command.
This means that your networking and disk image command line options are not making it into the qemu command line, which in turn is why it can't find the virtual disk image. The -nic error comes from treating the following as a new command:
"${net[#]}" \
6.858-x86_64-v22.vmdk
Solution:
Don't comment out the flag -enable-kvm \ in place: either remove the line entirely, or move it out of the command and comment it out there.

How to run Robot Framework's `robot` command from a shell/bash script on Windows?

As a user I want to execute Robot Framework's robot command with some command line options. I put everything in a script to avoid retyping the long command each time - see example below. On Linux an Mac OS I can execute this script from any terminal emulator, i.e.
# Linux
. run_local_tests.sh
# Mac OS
./run_local_tests.sh
On Windows an application (VSCode Editor) associated with .sh file type is opened instead of executing the robot command or an error like robot: command not found is returned
# Windows
.\run_local_tests.sh
# OR
run_local_tests.sh
# OR
bash run_local_tests.sh
shell script - filename: run_local_tests.sh
#!/bin/bash
# Set desired loglevel: NONE (less details), INFO, DEBUG, TRACE (most details)
export LOG_LEVEL=TRACE
# RUN CONTRIBUTION SERVICE TESTS
robot -i CONTRIBUTION -e circleci \
--outputdir results \
--log NONE \
--report NONE \
--output XML/CONTRIBUTION.xml \
--noncritical not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
--flattenkeywords name:_resources.* \
--loglevel $LOG_LEVEL \
--name CONTRI \
robot/CONTRIBUTION_TESTS/
Renaming the script from .sh to .bat doen't help :(
entering bash, then activating venv and calling the script doesn't work
What other options are there (without installing additional tools like Cygwin etc.)?
I'm actually trying to answer the same question in the opposite direction (how to trigger/run them on my machine as .sh). Looks like we may help each other out. 8)
I believe this is what you're looking for:
Your file would be run_local_tests.bat
Contents:
#echo off
cd C:\path\to\robot\project
call robot -d relative/path/to/test/output/dir relative/path/to/run_local_tests.bat
Of course you can use any other valid robot cli syntax in the call also. You may have to make it executable too. I'm not sure.

kubectl bash completion doesn't work in ubuntu docker container

I'm using kubectl from within a docker container running on a Mac. I've already successfully configured the bash completion for kubectl to work on the Mac, however, it doesn't work within the docker container. I always get bash: _get_comp_words_by_ref: command not found.
The docker image is based on ubuntu:16.04 and kubectl is installed via the line (snippet from the dockerfile)
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
mv kubectl /usr/local/bin
echo $BASH_VERSION gives me 4.3.48(1)-release, and according to apt, the bash-completionpackage is installed.
I'm using iTerm2 as terminal.
Any idea why it doesn't work or how to get it to work?
Ok, I found it - I simply needed to do a source /etc/bash_completion before or after the source <(kubectl completion bash).
check .bashrc
enable programmable completion features (you don't need to enable
this, if it's already enabled in /etc/bash.bashrc and /etc/profile
sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
A Linux container executed on macOS creates a separate environment and
yes, it looks like a thread from macOS shell, but it is not. Shell history,
properties, functions are a different story.
Moreover, if the container has no persistent volume mounted all of those parameters will be transisten and won’t survive container’s restart.
The approach to have bash completion of both of them - macOS and Ubuntu
Linux are similar, but require different steps to take:
macOS side - permanent support for kubectl bash completion:
use homebrew to install support:
brew install bash-completion
kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
Ubuntu container’s approach to have kubectl and bash completion support build in:
You can adapt this set of commands and use it in Dockerfile during the image preparation:
apt-get update && apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubectl
echo 'source <(kubectl completion bash)' >> ~/.bashrc
If afterwards you or user executes /bin/bash in running container then you should get completion working.
docker exec -it docker_image_id /bin/bash
this will start bash shell with the bash completion.
I united two top comments for Ubuntu 22.04
edit ~/.bashrc and add
source /etc/bash_completion
before
source <(kubectl completion bash)
alias k=kubectl
complete -o default -F __start_kubectl k

I2C not detecting ? issues in hardware or any other?

I have been working through some i2c examples. Plugging it all together and I find that I need to install the i2c-tools package, then use raspi-config to enable the I2C system.
The wiringPi gpio command has a shortcut to the i2cdetect command and running it gives
Before 3 weeks everything working properly, detected 68. I didn't understand what is the problem !!! Can anyone one help me to solve this issue.
The I2C bus allows multiple devices to be connected to your Raspberry Pi, each with a unique address, that can often be set by changing jumper settings on the module. It is very useful to be able to see which devices are connected to your Pi as a way of making sure everything is working.
To do this, it is worth running the following commands in the Terminal to install the i2c-tools utility.
sudo apt-get install -y python-smbus
sudo apt-get install -y i2c-tools
If you're not using a modern Raspbian or you want to do it by hand, you can! Open LXTerminal or console or ssh and enter the following command:
sudo nano /etc/modules
and add these two lines to the end of the file:
i2c-bcm2708
i2c-dev
Then save the file with Control-X Y
Depending on your distribution, you may also have a file called /etc/modprobe.d/raspi-blacklist.conf
If you do not have this file then there is nothing to do, however, if you do have this file, you need to edit it and comment out the lines below:
blacklist spi-bcm2708
blacklist i2c-bcm2708
.. by putting a # in front of them.
Open an editor on the file by typing:
sudo nano /etc/modprobe.d/raspi-blacklist.conf
If you are running a recent Raspberry Pi (3.18 kernel or higher) you will also need to update the /boot/config.txt file. Edit it with sudo nano /boot/config.txt and add the text
dtparam=i2c1=on
dtparam=i2c_arm=on
at the bottom. note that the "1" in "i2c1" is a one not an L!
Once this is all done, reboot!
Now when you log in you can type the following command to see all the connected devices
sudo i2cdetect -y 1
Note that if you are using one of the very first Raspberry Pis (a 256MB Raspberry Pi Model B) then you will need to change the command to:
sudo i2cdetect -y 0
Try sudo i2cdetect -y 1 or sudo i2cdetect -y 0 (if you using old Raspberry Pi) and run it on root. Open terminal and run command sudo su, then run sudo i2cdetect -y 1

Got black screen when recording screen by x11grab device

I'm trying to record video from a firefox run by xvfb-run but it always output nothing in the video file except black screen.
Here's what I did:
start a firefox, open google.com:
$ xvfb-run firefox https://google.com
Then it will use the default display server number 99. I can see the display information by command xdpyinfo -display :99.
A screenshot works very well by command:
$ xwd -root -silent -display :99.0 | xwdtopnm |pnmtojpeg > screen.jpg
Start using ffmpeg to record a video:
$ ffmpeg -f x11grab -i :99.0 out.mpg
When I play the video file out.mpg, there's black screen all the time.
Is there any parameter I missed?
I don't know if you have fixed this bug but if you haven't let me help out because I ran into same issue. Here's a solution (I'm running on Fedora 30):
Your need to Configuring Xorg as the default GNOME session. On your terminal open your custom.conf by typing the this command sudo nano /etc/gdm/custom.conf and uncomment WaylandEnable=false if it's commented but must be set to false
Then, on the [daemon] section just under WaylandEnable=false add this line DefaultSession=gnome-xorg.desktop and save the file. Then try running your Screen Recorder program again.
Congratulations.
However, if nano command is not working please try installing it by running the command
sudo dnf install nano or sudo apt-get install nano which ever works for you.

Resources