From a2f54f465e56e2a593f95763fc7f36db105e791c Mon Sep 17 00:00:00 2001 From: Felix Steghofer Date: Tue, 22 Jan 2019 23:43:52 +0100 Subject: [PATCH] update --- .config/i3/config | 7 +- .config/polybar/battery-combined-udev.pid | 2 +- .zsh/aliases.zsh | 4 +- .zshrc | 2 - bin/monitor-layout | 99 +++++++++++++++++++++++ bin/power-menu | 47 +++++++++++ bin/wlan-menu | 96 ++++++++++++++++++++++ 7 files changed, 251 insertions(+), 6 deletions(-) create mode 100755 bin/monitor-layout create mode 100755 bin/power-menu create mode 100755 bin/wlan-menu diff --git a/.config/i3/config b/.config/i3/config index ab0007a..7f4efcc 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -83,6 +83,11 @@ bindsym $mod+Shift+Down move down bindsym $mod+Shift+Up move up bindsym $mod+Shift+Right move right +bindsym $mod+mod1+Right resize shrink width 1 px or 1 ppt +bindsym $mod+mod1+Up resize grow height 1 px or 1 ppt +bindsym $mod+mod1+Down resize shrink height 1 px or 1 ppt +bindsym $mod+mod1+Left resize grow width 1 px or 1 ppt + # split in horizontal orientation bindsym $mod+h split h @@ -268,7 +273,7 @@ exec i3-msg workspace $ws1 # Start default applications exec_always --no-startup-id $HOME/.config/polybar/launch.sh -exec_always --no-startup-id $HOME/Pictures/Wallpapers/Annapurna.jpg +exec_always --no-startup-id nitrogen --head=0 --set-scaled $HOME/Pictures/Wallpapers/Annapurna.jpg exec_always --no-startup-id numlockx on exec_always --no-startup-id sudo tlp start exec --no-startup-id greenclip daemon diff --git a/.config/polybar/battery-combined-udev.pid b/.config/polybar/battery-combined-udev.pid index ba7a0b6..24a02ad 100644 --- a/.config/polybar/battery-combined-udev.pid +++ b/.config/polybar/battery-combined-udev.pid @@ -1 +1 @@ -7545 +32166 diff --git a/.zsh/aliases.zsh b/.zsh/aliases.zsh index 00a32a1..8d377da 100644 --- a/.zsh/aliases.zsh +++ b/.zsh/aliases.zsh @@ -75,8 +75,8 @@ alias x="exit" # Dateiendungen automatisch mit dem jeweiligen Programm öffnen alias -s html=$BROWSER -alias -s png=eog -alias -s jpg=eog +alias -s png=sxiv +alias -s jpg=sxiv alias -s org=$BROWSER alias -s php=$EDITOR alias -s com=$BROWSER diff --git a/.zshrc b/.zshrc index c9a2e42..a6d6412 100644 --- a/.zshrc +++ b/.zshrc @@ -220,8 +220,6 @@ if [ "$(hostname)" = "t480" ]; then PROMPT='%* %B%{%}%n%{%}@%U%m%u %{%}%~%b $(git_super_status) %# ' fi -numlockx on - if [ -z "$DISPLAY" -a $XDG_VTNR -eq 1 ]; then startx fi diff --git a/bin/monitor-layout b/bin/monitor-layout new file mode 100755 index 0000000..e51b3bb --- /dev/null +++ b/bin/monitor-layout @@ -0,0 +1,99 @@ +#!/bin/bash + +XRANDR=$(which xrandr) + +MONITORS=( $( ${XRANDR} | awk '( $2 == "connected" ){ print $1 }' ) ) + + +NUM_MONITORS=${#MONITORS[@]} + +TITLES=() +COMMANDS=() + + +function gen_xrandr_only() +{ + selected=$1 + + cmd="xrandr --output ${MONITORS[$selected]} --auto " + + for entry in $(seq 0 $((${NUM_MONITORS}-1))) + do + if [ $selected != $entry ] + then + cmd="$cmd --output ${MONITORS[$entry]} --off" + fi + done + + echo $cmd +} + + + +declare -i index=0 +TILES[$index]="Cancel" +COMMANDS[$index]="true" +index+=1 + + +for entry in $(seq 0 $((${NUM_MONITORS}-1))) +do + TILES[$index]="Only ${MONITORS[$entry]}" + COMMANDS[$index]=$(gen_xrandr_only $entry) + index+=1 +done + +## +# Dual screen options +## +for entry_a in $(seq 0 $((${NUM_MONITORS}-1))) +do + for entry_b in $(seq 0 $((${NUM_MONITORS}-1))) + do + if [ $entry_a != $entry_b ] + then + TILES[$index]="Dual Screen ${MONITORS[$entry_a]} -> ${MONITORS[$entry_b]}" + COMMANDS[$index]="xrandr --output ${MONITORS[$entry_a]} --auto \ + --output ${MONITORS[$entry_b]} --auto --left-of ${MONITORS[$entry_a]}" + + index+=1 + fi + done +done + + +## +# Clone monitors +## +for entry_a in $(seq 0 $((${NUM_MONITORS}-1))) +do + for entry_b in $(seq 0 $((${NUM_MONITORS}-1))) + do + if [ $entry_a != $entry_b ] + then + TILES[$index]="Clone Screen ${MONITORS[$entry_a]} -> ${MONITORS[$entry_b]}" + COMMANDS[$index]="xrandr --output ${MONITORS[$entry_a]} --auto \ + --output ${MONITORS[$entry_b]} --auto --same-as ${MONITORS[$entry_a]}" + + index+=1 + fi + done +done + + +## +# Generate entries, where first is key. +## +function gen_entries() +{ + for a in $(seq 0 $(( ${#TILES[@]} -1 ))) + do + echo $a ${TILES[a]} + done +} + +# Call menu +SEL=$( gen_entries | rofi -dmenu -p "Monitor Setup:" -a 0 -no-custom | awk '{print $1}' ) + +# Call xrandr +$( ${COMMANDS[$SEL]} ) diff --git a/bin/power-menu b/bin/power-menu new file mode 100755 index 0000000..263eaed --- /dev/null +++ b/bin/power-menu @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# rofi-power +# Use rofi to call systemctl for shutdown, reboot, etc + +# 2016 Oliver Kraitschy - http://okraits.de + +OPTIONS="Reboot system\nPower-off system\nSuspend system\nHibernate system" + +# source configuration or use default values +if [ -f $HOME/.config/rofi-power/config ]; then + source $HOME/.config/rofi-power/config +else + LAUNCHER="rofi -width 30 -dmenu -i -p rofi-power:" + USE_LOCKER="false" + LOCKER="i3lock" +fi + +# Show exit wm option if exit command is provided as an argument +if [ ${#1} -gt 0 ]; then + OPTIONS="Exit window manager\n$OPTIONS" +fi + +option=`echo -e $OPTIONS | $LAUNCHER | awk '{print $1}' | tr -d '\r\n'` +if [ ${#option} -gt 0 ] +then + case $option in + Exit) + eval $1 + ;; + Reboot) + systemctl reboot + ;; + Power-off) + systemctl poweroff + ;; + Suspend) + $($USE_LOCKER) && "$LOCKER"; systemctl suspend + ;; + Hibernate) + $($USE_LOCKER) && "$LOCKER"; systemctl hibernate + ;; + *) + ;; + esac +fi + diff --git a/bin/wlan-menu b/bin/wlan-menu new file mode 100755 index 0000000..139ebae --- /dev/null +++ b/bin/wlan-menu @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +# Starts a scan of available broadcasting SSIDs +# nmcli dev wifi rescan + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +FIELDS=SSID,SECURITY,IN-USE,RATE,SIGNAL,FREQ,CHAN,BARS + +LIST=$(nmcli --fields "$FIELDS" device wifi list | sed '/^--/d') +# For some reason rofi always approximates character width 2 short... hmmm +RWIDTH=$(($(echo "$LIST" | head -n 1 | awk '{print length($0); }')+2)) +# Dynamically change the height of the rofi menu +LINENUM=$(echo "$LIST" | wc -l) +# Gives a list of known connections so we can parse it later +KNOWNCON=$(nmcli connection show) +# Really janky way of telling if there is currently a connection +CONSTATE=$(nmcli -fields WIFI g) + +CURRSSID=$(iwgetid -r) + +if [[ ! -z $CURRSSID ]]; then + HIGHLINE=$(echo "$(echo "$LIST" | awk -F "[ ]{2,}" '{print $1}' | grep -Fxn -m 1 "$CURRSSID" | awk -F ":" '{print $1}') + 1" | bc ) +fi + +# HOPEFULLY you won't need this as often as I do +# If there are more than 8 SSIDs, the menu will still only have 8 lines +if [ "$LINENUM" -gt 8 ] && [[ "$CONSTATE" =~ "enabled" ]]; then + LINENUM=8 +elif [[ "$CONSTATE" =~ "disabled" ]]; then + LINENUM=1 +fi + + +if [[ "$CONSTATE" =~ "enabled" ]]; then + TOGGLE="toggle off" +elif [[ "$CONSTATE" =~ "disabled" ]]; then + TOGGLE="toggle on" +fi + +eval FIELDSARR=( $(cat ./config | awk 'BEGIN { FS=","; OFS="\n" } /^FIELDS/ { $1 = substr($1, 8); print $0; }') ) + +for i in "${!FIELDSARR[@]}"; do + if [[ "${FIELDSARR[$i]}" = "SSID" ]]; then + SSID_POS="${i}"; + fi +done + +let AWKSSIDPOS=$SSID_POS+1 + +CHENTRY=$(echo -e "$TOGGLE\nmanual\n$LIST" | uniq -u | rofi -dmenu -p "Wi-Fi SSID: " -lines "$LINENUM" -a "$HIGHLINE" -width -"$RWIDTH") +#echo "$CHENTRY" +CHSSID=$(echo "$CHENTRY" | sed 's/\s\{2,\}/\|/g' | awk -F "|" '{print $'$AWKSSIDPOS'}') +#echo "$CHSSID" + +# If the user inputs "manual" as their SSID in the start window, it will bring them to this screen +if [ "$CHENTRY" = "manual" ] ; then + # Manual entry of the SSID and password (if appplicable) + MSSID=$(echo "enter the SSID of the network (SSID,password)" | rofi -dmenu -p "Manual Entry: " -lines 1) + # Separating the password from the entered string + MPASS=$(echo "$MSSID" | awk -F "," '{print $2}') + + #echo "$MSSID" + #echo "$MPASS" + + # If the user entered a manual password, then use the password nmcli command + if [ "$MPASS" = "" ]; then + nmcli dev wifi con "$MSSID" + else + nmcli dev wifi con "$MSSID" password "$MPASS" + fi + +elif [ "$CHENTRY" = "toggle on" ]; then + nmcli radio wifi on + +elif [ "$CHENTRY" = "toggle off" ]; then + nmcli radio wifi off + +else + + # If the connection is already in use, then this will still be able to get the SSID + if [ "$CHSSID" = "*" ]; then + CHSSID=$(echo "$CHENTRY" | sed 's/\s\{2,\}/\|/g' | awk -F "|" '{print $3}') + fi + + # Parses the list of preconfigured connections to see if it already contains the chosen SSID. This speeds up the connection process + if [[ $(echo "$KNOWNCON" | grep "$CHSSID") = "$CHSSID" ]]; then + nmcli con up "$CHSSID" + else + if [[ "$CHENTRY" =~ "WPA2" ]] || [[ "$CHENTRY" =~ "WEP" ]]; then + WIFIPASS=$(echo "if connection is stored, hit enter" | rofi -dmenu -p "password: " -lines 1 ) + fi + nmcli dev wifi con "$CHSSID" password "$WIFIPASS" + fi + +fi