Skip to content

Instantly share code, notes, and snippets.

@bvaudour
bvaudour / 2.py
Last active August 29, 2015 14:10
Find kernel
import glob
import os
def get_kernel(mountpoint):
os.chdir(mountpoint)
kernels = [ file for file in glob.glob('*linux*') if os.path.isfile(os.path.join(mountpoint, f)) ]
return kernels
@bvaudour
bvaudour / 2.py
Created November 25, 2014 19:38
2.py
devices = ['/dev/sdc2']
osprober = ['/dev/sda2:KaOS (rolling):KaOS:linux', '/dev/sda3:KaOS (rolling):KaOS1:linux', '/dev/sdc2:KaOS (rolling):KaOS2:linux', '']
def write_conf(device):
title = ''
for l in osprober:
if device in l:
title = l
print(title)
@bvaudour
bvaudour / 1.py
Last active August 29, 2015 14:10
os-prober
import libcalamares
from libcalamares.utils import check_chroot_call
import subprocess
import os
install_path = libcalamares.globalstorage.value("rootMountPoint")
devices = []
distributions = ['linux_os']
osprober = []
@bvaudour
bvaudour / srename.sh
Last active August 29, 2015 14:10
Secure rename with perl-rename
#!/bin/bash
perl-rename -n $@
echo -en "\033[1;33m\nProceed? \033[m"
read yesno
case "$yesno" in
O*|o*|Y*|y*) perl-rename -v $@;;
*) echo -e "\033[1;31mCancel...\033[m"
esac
exit 0
@bvaudour
bvaudour / sddm.py
Last active August 29, 2015 14:08
Example of sddm config
p = subprocess.Popen(["sddm", "--example-config"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
install_path = 'test'
sddm_conf_path = os.path.join(install_path, 'sddm.conf')
if p.stderr:
print('Unsuccessful command')
else:
lines = p.stdout.read().decode()
with open(sddm_conf_path, 'w') as f:
f.write(lines)
f.close()
@bvaudour
bvaudour / main.py
Last active August 29, 2015 14:07
Function to create kaos.conf
def create_conf(uuid, conf_path):
lines = [
'## This is just an example config file.\n',
'## Please edit the paths and kernel parameters according to your system.\n',
'\n',
'title KaOS GNU/Linux, with Linux core repo kernel\n',
'linux /vmlinuz-linux\n',
'initrd /initramfs-linux.img\n',
'options root=%s quiet rw\n' % uuid,
]
@bvaudour
bvaudour / PKGBUILD
Last active August 29, 2015 14:05
mpv PKGBUILD
pkgname=mpv
pkgver=0.5.1
pkgrel=1
pkgdesc='Video player based on MPlayer/mplayer2'
arch=('x86_64')
license=('GPL')
url='http://mpv.io'
depends=(
'ffmpeg' 'lcms2' 'libdvdread' 'libcdio-paranoia' 'libgl' 'enca'
'libxinerama' 'mpg123' 'libxv' 'libxkbcommon' 'libva' 'wayland'
@bvaudour
bvaudour / remove.py
Created August 1, 2014 20:46
Secure pacman remove
try:
self.chroot(['pacman', '-Rdd', '--noconfirm', 'xf86-video-nouveau'])
except Exception, e:
pass
@bvaudour
bvaudour / input.py
Last active August 29, 2015 14:04
Input drivers
# For input
with open(path_to_file) as f:
has_synaptics, has_wacom = False, False
for line in f:
if not has_synaptics and "synaptics" in line:
has_synaptics = True
if not has_wacom and "wacom" in line:
has_wacom = True
if has_synaptics and has_wacom:
break
@bvaudour
bvaudour / inputdrv.py
Last active August 29, 2015 14:04
simplify...
print(listOfPkgsv)
# Remove the pkgs that do not have 'thisVideo'
for pkg in listOfPkgsv:
if pkg.find(thisVideo) == -1:
self.queue_event('info', _("Removing video drivers (packages)"))
self.chroot(['pacman', '-Rncs', '--noconfirm', 'xf86-video-%s' % (pkg)])
# Cleanup input drivers
with open("/var/log/Xorg.0.log", "r") as searchfile: