Skip to content

Instantly share code, notes, and snippets.

@Nama
Nama / motd.sh
Last active January 12, 2018 19:15
motd for logins. Just put in /etc/profile.d/
#!/bin/bash
freemem=`cat /proc/meminfo|grep 'MemF'| awk '{print int($2/1024)}'`
totalmem=`cat /proc/meminfo|grep 'MemT'| awk '{print int($2/1024)}'`
usedmem=`echo $totalmem-$freemem | bc`
echo -e "
\033[1;34mHi $USER!\033[0;37m
\033[0;90m+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\033[0;90m+ \033[1;94mHostname....: \033[36m$(hostname)
\033[0;90m+ \033[1;94mKernel......: \033[36m$(uname -r)
@Nama
Nama / color_ranks.py
Last active March 20, 2016 21:36
Custom user colors by user mode. Only effects the chat, not the userlist.
import hexchat
__module_name__ = 'color ranks'
__module_author__ = 'Yama'
__module_version__ = '0.1'
__module_description__ = 'Make user colors by rank'
def mod_colors(word, word_eol, userdata):
nickname = hexchat.strip(word[0], len(word[0]), 1)
nickname += '\003'
@Nama
Nama / tg_bot.py
Last active July 8, 2019 13:11
Short script to send messages via Telegram-Bot
#!python
import sys
import requests
from socket import gethostname
from sys import argv
link = 'https://api.telegram.org/bot'
token = 'BotToken'
@Nama
Nama / kodi_youtube_link.py
Created May 7, 2016 13:34
Send various Youtube-Links to kodi over TCP. No need for the webinterface. TCP needs to be enabled. List and Channel links arent implemented yet.
@Nama
Nama / mnthdd.sh
Last active June 8, 2016 11:40
Easy mount devices encrypted with cryptsetup. I use this code in /etc/profile.d/
#!/bin/bash
mnthdd() {
# The full mount-path is put together bei $MOUNTPATH and $DRIVES
# In this example it would be /media/ + your parameter
MOUNTPATH="/media/"
# /etc/fstab
## hdd1
#/dev/mapper/hdd1 /media/hdd1 ext4 noauto,defaults 0 0
#
@Nama
Nama / hibernate.sh
Last active June 11, 2016 12:35
Script for Arch Linux. Hibernate can't continue if a new kernel is installed. So this script instead suggests to shutdown. Put in /etc/profile.d/ and run via command "hibernate". Should work with LTS and GRSEC kernels, too.
#!/bin/bash
KERNEL="/boot/vmlinuz-linux"
hibernate() {
grep $(uname -r) $KERNEL* > /dev/null
if [[ $? == 0 ]]; then
echo "Newest kernel is running, hibernating..."
systemctl hibernate
else
echo "New kernel is installed, can't continue after hibernate..."
@Nama
Nama / rss_noc.py
Created September 29, 2016 22:19
Parse the news site https://noc.rub.de and serve the headlines as RSS feeds. Using Flask
#!/usr/bin/env python
from flask import Flask, request, url_for
from werkzeug.contrib.atom import AtomFeed
from html.parser import HTMLParser
import urllib.request
from datetime import datetime
app = Flask(__name__)
url_noc = 'https://noc.rub.de/cgi-bin/status/'
@Nama
Nama / arch_system_upgrade.py
Created November 7, 2019 14:06
update and notify about updates
#!/usr/bin/python
from sh import hostname, checkupdates, yay, touch
from tg_bot import send
chatid = '000000000'
updates = checkupdates()
if updates:
@Nama
Nama / i3.py
Created November 7, 2019 15:39
#!/usr/bin/python
import os
import i3ipc
import sys
import pickle
PATH = os.path.expanduser("~/.config/i3/workspace_mapping")
def showHelp():
#!/bin/bash
#/etc/udev/rules.d/95-monitor-hotplug.rules
#KERNEL=="card0", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/yama/.Xauthority", RUN+="/home/yama/scripts/monitor-hotplug.sh"
# udevadm control --reload-rules && udevadm trigger
xrandr | grep -q "DP2-8 connected"
connected1=$?
xrandr | grep -q "DP2-1-8 connected"