Running with Ruby

Category: Linux (page 1 of 24)

Ubuntu 18.04 – Disable screen on lid close

In order to force your Ubuntu to just disable the screen on lid close, you need to do two things:

  1. Disable sleep (do nothing) on lid close
  2. Disable screen on lid close

Just follow all the steps from both sections and you should be fine.

Disable sleep (do nothing) on lid close

Copy-paste this into the terminal (as a root):

# sudo su
echo 'HandleLidSwitch=ignore' | tee --append /etc/systemd/logind.conf
echo 'HandleLidSwitchDocked=ignore' | tee --append /etc/systemd/logind.conf
sudo service systemd-logind restart

Disable screen on lid close

Copy-paste this into the terminal (as a root):

# sudo su
echo 'event=button/lid.*' | tee --append /etc/acpi/events/lm_lid
echo 'action=/etc/acpi/lid.sh' | tee --append /etc/acpi/events/lm_lid
touch /etc/acpi/lid.sh
chmod +x /etc/acpi/lid.sh

Edit the /etc/acpi/lid.sh file, paste following content and replace the your_username with your main user name:

#!/bin/bash

USER=your_username

grep -q close /proc/acpi/button/lid/*/state

if [ $? = 0 ]; then
  su -c  "sleep 1 && xset -display :0.0 dpms force off" - $USER
fi

grep -q open /proc/acpi/button/lid/*/state

if [ $? = 0 ]; then
  su -c  "xset -display :0 dpms force on &> /tmp/screen.lid" - $USER
fi

Apache Zookeeper + Apache Kafka start / restart script

During my  work on Karafka framework I have to start/stop/restart Apache Kafka and Zookeeper quite often. Here’s a short script that will pull the most recent version of Kafka and Zookeeper, will run them and print their IPs.

Note, that it will also stop Kafka and Zookeeper if they were running.

ZOOKEEPER_CHROOT='/kafka'

docker stop zookeeper
docker stop kafka
docker rm zookeeper
docker rm kafka

docker pull jplock/zookeeper
docker pull ches/kafka

docker run \
  -d \
  -e ZOOKEEPER_CHROOT=$ZOOKEEPER_CHROOT \
  --name zookeeper \
  jplock/zookeeper:3.4.6

docker run \
  -d \
  -e ZOOKEEPER_CHROOT=$ZOOKEEPER_CHROOT \
  --name kafka \
  --link zookeeper:zookeeper \
  ches/kafka

ZOOKEEPER_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' zookeeper)
KAFKA_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' kafka)

echo "Zookeeper chroot: $ZOOKEEPER_CHROOT"
echo "Zookeeper: $ZOOKEEPER_IP"
echo "Kafka: $KAFKA_IP"
Olderposts

Copyright © 2018 Running with Ruby

Theme by Anders NorenUp ↑