Kernel formatting

This commit is contained in:
John Mertz 2020-11-23 04:35:26 -05:00 committed by John Mertz
parent b161ad6423
commit a4f2b3310c
Signed by: jpm
GPG Key ID: E9C5EA2D867501AB
28 changed files with 1451 additions and 1234 deletions

102
README.md
View File

@ -1,39 +1,51 @@
# Simple Scripts
## Audio
**audio/mute.sh**
Just a simple script to toggle Alsa mute.
---
**audio/noise-cancel.sh**
Add a noise-cancelled version of existing interfaces to Pulseaudio.
## i3
I haven't used i3 in earnest for quite some time since moving to Sway, so it is very likely that some of these scripts are broken based on other config changes.
I haven't used i3 in earnest for quite some time since moving to Sway, so it is
very likely that some of these scripts are broken based on other config changes.
**i3/i3move.sh**
When any of the Xrandr scripts below is run, it will print it's name to a config file. This script will read that config file and then knows how the outputs are arranged. Once this is known, it allows hotkeys to know which output to move a workspace to.
When any of the Xrandr scripts below is run, it will print it's name to a config
file. This script will read that config file and then knows how the outputs are
arranged. Once this is known, it allows hotkeys to know which output to move a
workspace to.
**i3/detached.sh**
Xrandr config. Just the laptop display.
**i3/work.sh**
**i3/detached.sh**
Xrandr config. Vertical on the left, horizontal aligned to top of the vertical, and laptop directly below that. Left-to-right order is Vertical-Horizontal-Laptop.
Xrandr config. Just the laptop display.
**i3/home.sh**
Xrandr config. Not a layout I currently use. Home is now the "stacked" view from sway/displays.
Xrandr config. Not a layout I currently use. Home is now the "stacked" view from
sway/displays.
**i3/work.sh**
Xrandr config. Vertical on the left, horizontal aligned to top of the vertical,
and laptop directly below that. Left-to-right order is
Vertical-Horizontal-Laptop.
## Rofi
[Rofi](https://github.com/davatorium/rofi) is a neat graphical launcher and menu system. I use it for a bunch of stuff to supplement i3 and Sway to fill out same desktop niceties. See configs in 'dotfiles' repository.
[Rofi](https://github.com/davatorium/rofi) is a neat graphical launcher and menu
system. I use it for a bunch of stuff to supplement i3 and Sway to fill out same
desktop niceties. See configs in 'dotfiles' repository.
**rofi/drun.sh**
@ -53,7 +65,8 @@ Forward pasted link to ./send-to-kodi.sh.
**rofi/rofi-ssh-menu.sh**
Open a terminal to any SSH shortcut machine. (TODO: Integrate with 'sshs' to get machine list from there instead of a static list).
Open a terminal to any SSH shortcut machine. (TODO: Integrate with 'sshs' to get
machine list from there instead of a static list).
**rofi/sway-alt-tab.sh**
@ -61,27 +74,40 @@ Show all currently running applications in Sway to locate window.
## Sway
[Sway](https://github.com/swaywm/sway) is an i3-compatible Wayland compositor and tiling window manager. See configs in 'dotfiles' repository. Here are some scripts exclusively for automating or enhancing Sway.
[Sway](https://github.com/swaywm/sway) is an i3-compatible Wayland compositor
and tiling window manager. See configs in 'dotfiles' repository. Here are some
scripts exclusively for automating or enhancing Sway.
**sway/displays.pl**
Script to automatically configure wayland outputs using swaymsg. Also forks waybars for each display. Allows custom configurations. No argument will run the last used configuration (~/config/last_display). '-w' will run only waybar without changing displays.
Script to automatically configure wayland outputs using swaymsg. Also forks
waybars for each display. Allows custom configurations. No argument will run the
last used configuration (~/config/last_display). '-w' will run only waybar
without changing displays.
**sway/gammastep.pl**
Setup Gammastep based on current location. I don't have geolocation in my laptop, so this requires a URL that returns JSON, including a "lat" and "lon". My URL (restricted to my IPs) returns these as recorded by PhoneTrack on my phone similar to:
Setup Gammastep based on current location. I don't have geolocation in my
laptop, so this requires a URL that returns JSON, including a "lat" and "lon".
My URL (restricted to my IPs) returns these as recorded by PhoneTrack on my
phone similar to:
```
{"lat":"180.12345678","lon":"-180.12345678","timestamp":"1599831660"}
```
It forks to keep running if terminal is killed to remove the need for nohup. If location fails to be fetched it will try again every 5 seconds.
It forks to keep running if terminal is killed. If location fails to be fetched
it will try again every 5 seconds.
**sway/popup-term.pl**
A DIY version of the Tilde terminal. If terminal is not running, it opens on the current display. If it is running but not on current display, it moves to current display. If it is already on current display, it is moved to a hidden display ('grave').
A DIY version of the Tilde terminal. If terminal is not running, it opens on the
current display. If it is running but not on current dislpay, it moves to
current display. If it is already on current display, it is moved to a hidden
display ('grave').
Note the relevant settings in dotfiles repository (sway/config) related to the 'grave' workspace, as well as UXTerm which is configured to open floating in the bottom corner.
Note the relevant settings in dotfiles repository (sway/config) related to the
'grave' workspace, as well as UXTerm.
```
for_window [class="UXTerm"] floating enable, resize set height 600px, resize set width 800px, move position 1120px 460px
@ -91,7 +117,8 @@ bindsym $mod+Grave exec /home/jpm/scripts/sway/popup-term.pl
bindsym $mod+Shift+Grave workspace grave
```
Also note that 'grave' has no label in waybar (waybar/config.template) to allow it to be *hidden*.
Also note that 'grave' has no label in waybar (waybar/config.template) to allow
it to be *hidden*.
```
"sway/workspaces": {
@ -106,35 +133,44 @@ Also note that 'grave' has no label in waybar (waybar/config.template) to allow
Work in progress. These scripts don't currently work the way I like.
Sway has an Idle detection daemon that can flexibly take different actions after certain periods of inactivity as well as prior to sleep and after wake.
Sway has an Idle detection daemon that can flexibly take different actions after
certain periods of inactivity as well as prior to sleep and after wake.
This script is meant to unify all of the actions into one script by accepting an option.
This script is meant to unify all of the actions into one script by accepting an
option.
**sway/swayidlecountdown.sh**
Prior to locking, a countdown should be provided. Currently testing how to manage a countdown with Dunst, which doesn't actually support dynamic notifications.
**sway/toggle_outputs**
Swap between detached and docked modes using `sway/displays.pl`. Bound to function key for external monitor button.
Prior to locking a countdown should be provided. Currently testing how to manage
a countdown with Dunst, which doesn't actually support dynamic notifications.
## Thinkpad
**thinkpad/blc.pl**
Overly complicated backlight brightness control script. Provides flexible control of backlight so that changes can be easily scripted or called from keyboard shortcuts. --help provides some usage docs.
Overly complicated backlight brightness control script. Provides flexible
control of backlight so that changes can be easily scripted or called from
keyboard shortcuts. --help provides some usage docs.
**thinkpad/kbd_backlight.pl**
Simple script to cycle keyboard backlight. Gets max brightness, current brightness and then changes then increments the current brightness. Uses mod of max+1 so that it will cycle back around to 0 (disabled) if it is already at max.
Simple script to cycle keyboard backlight. Gets max brightness, current
brightness and then changes then increments the current brightness. Uses mod of
max+1 so that it will cycle back around to 0 (disabled) if it is already at max.
**thinkpad/user-thinkpad-control@.service**
SystemD unit file used to give ownership of necessary sys files to whichever user it is enabled for `systemctl enable user-thinkpad-control@jpm`. Without this, the user won't be able to write these files and thus cannot set brightness values.
SystemD unit file used to give ownership of necessary sys files to whichever
user it is enabled for `systemctl enable user-thinkpad-control@jpm`. Without
this, the user won't be able to write these files and thus cannot set brightness
values.
## Waybar
[Waybar](https://github.com/Alexays/Waybar) is a very flexible and customizable taskbar for Sway (and other Wlroots-based wayland compositors). Waybar applets have hover and click functionality and have several scripts related to those. See the .config repository for the actual Waybar and Sway configs.
[Waybar](https://github.com/Alexays/Waybar) is a very flexible and customizable
taskbar for Sway (and other Wlroots-based wayland compositors). Waybar applets
have hover and click functionality and have several scripts related to those.
See the .config repository for the actual Waybar and Sway configs.
**waybar/waybar-cpu.sh**
@ -142,7 +178,8 @@ Launch htop in floating window (bottom-right). If already running, kill it.
**waybar/waybar-disk.sh**
Notification with disk usage summaries. Renders properly with Dunst, but not Mako.
Notification with disk usage summaries. Renders properly with Dunst, but not
Mako.
**waybar/waybar-mem.sh**
@ -156,8 +193,13 @@ Launch nmtui in floating window (bottom-right). If already running, kill it.
**send-to-kodi.sh**
[This script](https://github.com/allejok96/send-to-kodi) sends a URL or local file to a [Kodi](https://github.com/xbmc) media player. Only modified to have my local media server IP.
[This script](https://github.com/allejok96/send-to-kodi) sends a URL or local
file to a [Kodi](https://github.com/xbmc) media player. Only modified to have my
local media server IP.
**apply-gruvbox.sh**
A single theme version of the one provided [here](https://raw.githubusercontent.com/Mayccoll/Gogh). Applies the theme to a variety of terminals. Not really necessary after cloning the 'dotfiles' repository.
A single theme version of the one provided
[here](https://raw.githubusercontent.com/Mayccoll/Gogh). Applies the theme to a
variety of terminals. Not really necessary after cloning the 'dotfiles'
repository.

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash
# Single theme copy of apply-colors.sh from: https://raw.githubusercontent.com/Mayccoll/Gogh
# Single theme copy of apply-colors.sh from:
# https://raw.githubusercontent.com/Mayccoll/Gogh
# ====================CONFIG THIS =============================== #
export COLOR_01="#282828" # HOST
@ -65,8 +66,9 @@ GLOBAL_VAR_CLEANUP() {
unset PROFILE_NAME
}
# Note: Since all scripts gets invoked in a subshell the traps from the parent shell
# will not get inherited. Hence traps defined in gogh.sh and print-themes.sh will still trigger
# Note: Since all scripts gets invoked in a subshell the traps from the parent
# shell will not get inherited. Hence traps defined in gogh.sh and
# print-themes.sh will still trigger
trap 'GLOBAL_VAR_CLEANUP; trap - EXIT' EXIT HUP INT QUIT PIPE TERM
# | ===========================================
@ -107,16 +109,15 @@ case "${TERMINAL}" in
exit 1
fi
;;
mintty )
CFGFILE="${HOME}/.minttyrc"
if [[ ! -f "${CFGFILE}" ]]; then
printf '\n%s\n' "Warning: Couldn't find an existing configuration file, so one will be created for you."
printf '\n%s\n' "Warning: Couldn't find an existing configuration file, \
so one will be created for you."
printf '%s\n\n' "Warning: Are you really running Cygwin's mintty?"
touch "${CFGFILE}"
fi
;;
guake|tilix|mate-terminal|gnome-terminal* )
case "${TERMINAL}" in
guake|gnome-terminal* )
@ -135,7 +136,6 @@ case "${TERMINAL}" in
exit 1
fi
;;
esac
# | ===========================================
@ -190,7 +190,8 @@ updateMinttyConfig () {
local color="${2}"
local name="${3}"
sed -i -r -e "s/^${name}=.+/$(createMinttyEntry "${name}" "${color}")/g" "${config}"
sed -i -r -e "s/^${name}=.+/$(createMinttyEntry "${name}" \
"${color}")/g" "${config}"
}
convertNameAndRGBtoITerm() {
@ -200,7 +201,9 @@ convertNameAndRGBtoITerm() {
set -- $(convertRGBtoMac "${color}")
R=${1}; shift; G=${1}; shift; B=${1}; shift
echo "<key>${name}</key><dict><key>Blue Component</key><real>${B}</real><key>Green Component</key><real>${G}</real><key>Red Component</key><real>${R}</real></dict>"
echo "<key>${name}</key><dict><key>Blue Component</key><real>${B}\
</real><key>Green Component</key><real>${G}</real><key>Red Component</key>\
<real>${R}</real></dict>"
}
dset() {
@ -218,9 +221,11 @@ dlist_append() {
entries="$(
{
"${DCONF}" read "${key}" | tr -d "[]" | tr , "\n" | grep -F -v "${val}"
"${DCONF}" read "${key}" | tr -d "[]" | tr , "\n" | \
grep -F -v "${val}"
echo "'${val}'"
} | head -c-1 | tr "\n" ,
} \
| head -c-1 | tr "\n" ,
)"
"${DCONF}" write "${key}" "[${entries}]"
@ -243,12 +248,15 @@ glist_append() {
entries="$(
{
"${GCONF}" --get "${key}" | tr -d "[]" | tr , "\n" | grep -F -v "${val}"
"${GCONF}" --get "${key}" | tr -d "[]" | tr , "\n" | \
grep -F -v "${val}"
echo "${val}"
} | head -c-1 | tr "\n" ,
}\
| head -c-1 | tr "\n" ,
)"
"${GCONF}" --set --type list --list-type "${type}" "${key}" "[${entries}]"
"${GCONF}" --set --type list --list-type "${type}" "${key}" \
"[${entries}]"
}
gset() {
@ -267,7 +275,8 @@ set_theme() {
dset highlight-colors-set "true"
dset highlight-background-color "'${HIGHLIGHT_BG_COLOR}'"
if [[ -n "${HIGHLIGHT_FG_COLOR:-}" ]]; then
dset highlight-foreground-color "'${HIGHLIGHT_FG_COLOR}'"
dset highlight-foreground-color \
"'${HIGHLIGHT_FG_COLOR}'"
fi
fi
@ -300,9 +309,11 @@ legacy_set_theme() {
}
# | ===========================================
# | If terminal supports truecolor then we can show theme colors without applying the theme
# | If terminal supports truecolor then we can show theme colors without
# | applying the theme
# | ===========================================
if [[ "${COLORTERM:-}" == "truecolor" ]] || [[ "${COLORTERM:-}" == "24bit" ]]; then
if [[ "${COLORTERM:-}" == "truecolor" ]] || [[ "${COLORTERM:-}" == "24bit" ]]
then
# gogh_colors have been moved here to avoid multiple definitions
function gogh_colors () {
# Build up the color string to avoid visual rendering
@ -312,8 +323,10 @@ if [[ "${COLORTERM:-}" == "truecolor" ]] || [[ "${COLORTERM:-}" == "24bit" ]]; t
local color="COLOR_$c"
set -- $(hexRGBtoDecRGB "${!color}")
color_str+="\033[38;2;${1};${2};${3}m█████$(tput sgr0)"
[[ ${GOGH_DRY_RUN:-0} -eq 1 ]] && export "DEMO_COLOR_$c=\033[38;2;${1};${2};${3}m"
[[ "$c" == "08" ]] && color_str+="\n" # new line
[[ ${GOGH_DRY_RUN:-0} -eq 1 ]] && \
export "DEMO_COLOR_$c=\033[38;2;${1};${2};${3}m"
[[ "$c" == "08" ]] && \
color_str+="\n" # new line
done
printf '\n%b\n\n\n' "${color_str}"
unset color_str
@ -389,24 +402,42 @@ apply_darwin() {
# | Applying values on iTerm2
# | ===========================================
BACKGROUND_COLOR=$(convertNameAndRGBtoITerm "Background Color" "$BACKGROUND_COLOR")
FOREGROUND_COLOR=$(convertNameAndRGBtoITerm "Foreground Color" "$FOREGROUND_COLOR")
COLOR_01=$(convertNameAndRGBtoITerm "Ansi 0 Color" "$COLOR_01")
COLOR_02=$(convertNameAndRGBtoITerm "Ansi 1 Color" "$COLOR_02")
COLOR_03=$(convertNameAndRGBtoITerm "Ansi 2 Color" "$COLOR_03")
COLOR_04=$(convertNameAndRGBtoITerm "Ansi 3 Color" "$COLOR_04")
COLOR_05=$(convertNameAndRGBtoITerm "Ansi 4 Color" "$COLOR_05")
COLOR_06=$(convertNameAndRGBtoITerm "Ansi 5 Color" "$COLOR_06")
COLOR_07=$(convertNameAndRGBtoITerm "Ansi 6 Color" "$COLOR_07")
COLOR_08=$(convertNameAndRGBtoITerm "Ansi 7 Color" "$COLOR_08")
COLOR_09=$(convertNameAndRGBtoITerm "Ansi 8 Color" "$COLOR_09")
COLOR_10=$(convertNameAndRGBtoITerm "Ansi 9 Color" "$COLOR_10")
COLOR_11=$(convertNameAndRGBtoITerm "Ansi 10 Color" "$COLOR_11")
COLOR_12=$(convertNameAndRGBtoITerm "Ansi 11 Color" "$COLOR_12")
COLOR_13=$(convertNameAndRGBtoITerm "Ansi 12 Color" "$COLOR_13")
COLOR_14=$(convertNameAndRGBtoITerm "Ansi 13 Color" "$COLOR_14")
COLOR_15=$(convertNameAndRGBtoITerm "Ansi 14 Color" "$COLOR_15")
COLOR_16=$(convertNameAndRGBtoITerm "Ansi 15 Color" "$COLOR_16")
BACKGROUND_COLOR=$(convertNameAndRGBtoITerm "Background Color" \
"$BACKGROUND_COLOR")
FOREGROUND_COLOR=$(convertNameAndRGBtoITerm "Foreground Color" \
"$FOREGROUND_COLOR")
COLOR_01=$(convertNameAndRGBtoITerm "Ansi 0 Color" \
"$COLOR_01")
COLOR_02=$(convertNameAndRGBtoITerm "Ansi 1 Color" \
"$COLOR_02")
COLOR_03=$(convertNameAndRGBtoITerm "Ansi 2 Color" \
"$COLOR_03")
COLOR_04=$(convertNameAndRGBtoITerm "Ansi 3 Color" \
"$COLOR_04")
COLOR_05=$(convertNameAndRGBtoITerm "Ansi 4 Color" \
"$COLOR_05")
COLOR_06=$(convertNameAndRGBtoITerm "Ansi 5 Color" \
"$COLOR_06")
COLOR_07=$(convertNameAndRGBtoITerm "Ansi 6 Color" \
"$COLOR_07")
COLOR_08=$(convertNameAndRGBtoITerm "Ansi 7 Color" \
"$COLOR_08")
COLOR_09=$(convertNameAndRGBtoITerm "Ansi 8 Color" \
"$COLOR_09")
COLOR_10=$(convertNameAndRGBtoITerm "Ansi 9 Color" \
"$COLOR_10")
COLOR_11=$(convertNameAndRGBtoITerm "Ansi 10 Color" \
"$COLOR_11")
COLOR_12=$(convertNameAndRGBtoITerm "Ansi 11 Color" \
"$COLOR_12")
COLOR_13=$(convertNameAndRGBtoITerm "Ansi 12 Color" \
"$COLOR_13")
COLOR_14=$(convertNameAndRGBtoITerm "Ansi 13 Color" \
"$COLOR_14")
COLOR_15=$(convertNameAndRGBtoITerm "Ansi 14 Color" \
"$COLOR_15")
COLOR_16=$(convertNameAndRGBtoITerm "Ansi 15 Color" \
"$COLOR_16")
# Assemble color scheme file contents
ITERMCOLORS='<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict>'${BACKGROUND_COLOR}${FOREGROUND_COLOR}${COLOR_01}${COLOR_02}${COLOR_03}${COLOR_04}${COLOR_05}${COLOR_06}${COLOR_07}${COLOR_08}${COLOR_09}${COLOR_10}${COLOR_11}${COLOR_12}${COLOR_13}${COLOR_14}${COLOR_15}'</dict></plist>'
@ -436,7 +467,8 @@ apply_gtk() {
# Check first wether profile already exists
profile_hashes=($(${CONFTOOL} "${PROFILE_LIST_KEY}" | tr "[]'," " "))
for profile in "${profile_hashes[@]}"; do
if [[ "$(${CONFTOOL} "${BASE_DIR}${profile}/${VISIBLE_NAME}" | tr -d "'")" == "${PROFILE_NAME}" ]]; then
if [[ "$(${CONFTOOL} "${BASE_DIR}${profile}/${VISIBLE_NAME}" | \
tr -d "'")" == "${PROFILE_NAME}" ]]; then
printf '%s\n' "Profile already exists" "Skipping..."
exit 0
fi
@ -453,13 +485,16 @@ apply_gtk() {
PROFILE_KEY="${BASE_DIR}${PROFILE_SLUG:-}"
if [[ -z "${legacy}" ]]; then
# Provide a user friendly error text if no saved profile exists,
# otherwise it will display "Error gconftool not found!"
# it could happen on a newly installed system
if [[ -z "$(${DCONF} list ${BASE_DIR%:})" ]]; then
# Provide a user friendly error text if no saved profile exists, otherwise it will display "Error gconftool not found!"
# it could happen on a newly installed system. (happened on CentOS 7)
printf '%s\n' \
"Error, no saved profiles found!" \
"Possible fix, new a profile (Terminal > Edit > Preferences > Profiles > New, then Close) and try again." \
"You can safely delete the created profile after the installation."
"Possible fix, new a profile (Terminal > Edit > Pref\
erences > Profiles > New, then Close) and try again." \
"You can safely delete the created profile after the\
installation."
exit 1
fi
@ -485,7 +520,8 @@ apply_gtk() {
COLOR_16=$(gnome_color "$COLOR_16")
# copy existing settings from default profile
$DCONF dump "${DEFAULT_KEY}/" | $DCONF load "${PROFILE_KEY}/"
$DCONF dump "${DEFAULT_KEY}/" | \
$DCONF load "${PROFILE_KEY}/"
# add new copy to global list of profiles
dlist_append "${PROFILE_LIST_KEY}" "${PROFILE_SLUG#:}"

View File

@ -1,6 +1,7 @@
# Microphone Realtime background noise reduction script
# author Luigi Maselli - https://grigio.org licence: AS-IS
# credits: http://askubuntu.com/questions/18958/realtime-noise-removal-with-pulseaudio
# credits:
# http://askubuntu.com/questions/18958/realtime-noise-removal-with-pulseaudio
# run as: sudo && pulseaudio -k
sudo cp /etc/pulse/default.pa /etc/pulse/default.pa.bak

View File

@ -1,3 +1,10 @@
#!/bin/sh
xrandr --output DP-2-1 --off --output DP-2-2 --off --output DP-2-3 --off --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-2 --off --output HDMI-1 --off --output DP-2 --off --output DP-1 --off
xrandr \
--output DP-2-1 --off \
--output DP-2-2 --off \
--output DP-2-3 --off \
--output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal \
--output HDMI-2 --off \
--output HDMI-1 --off --output DP-2 --off --output DP-1 --off
echo "detached" > ~/.config/screenlayout/i3.current

View File

@ -1,3 +1,12 @@
#!/bin/sh
xrandr --output DP-2-1 --mode 1366x768 --pos 0x0 --rotate left --output DP-2-2 --mode 1920x1200 --pos 768x0 --rotate normal --output DP-2-3 --off --output eDP-1 --primary --mode 1920x1080 --pos 768x1200 --rotate normal --output HDMI-2 --off --output HDMI-1 --off --output DP-2 --off --output DP-1 --off
xrandr \
--output DP-2-1 --mode 1366x768 --pos 0x0 --rotate left \
--output DP-2-2 --mode 1920x1200 --pos 768x0 --rotate normal \
--output DP-2-3 --off \
--output eDP-1 --primary --mode 1920x1080 --pos 768x1200 --rotate normal \
--output HDMI-2 --off \
--output HDMI-1 --off \
--output DP-2 --off \
--output DP-1 --off
echo "home" > ~/.config/screenlayout/i3.current

View File

@ -1,3 +1,12 @@
#!/bin/sh
xrandr --output DP-2-1 --mode 1920x1080 --pos 0x0 --rotate left --output DP-2-2 --mode 1920x1080 --pos 1080x0 --rotate normal --output DP-2-3 --off --output eDP-1 --primary --mode 1920x1080 --pos 1080x1080 --rotate normal --output HDMI-2 --off --output HDMI-1 --off --output DP-2 --off --output DP-1 --off
xrandr \
--output DP-2-1 --mode 1920x1080 --pos 0x0 --rotate left \
--output DP-2-2 --mode 1920x1080 --pos 1080x0 --rotate normal \
--output DP-2-3 --off \
--output eDP-1 --primary --mode 1920x1080 --pos 1080x1080 --rotate normal \
--output HDMI-2 --off \
--output HDMI-1 --off \
--output DP-2 --off \
--output DP-1 --off
echo "work" > ~/.config/screenlayout/i3.current

View File

@ -1,5 +1,6 @@
#!/bin/bash
INPUT="$(rofi -dmenu -i -p 'Kodi:' "" -columns 1 -rows 7 -width 32 -l 1 -hide-scrollbar -eh 1 -location 0 -padding 12 -opacity 100)"
INPUT="$(rofi -dmenu -i -p 'Kodi:' "" -columns 1 -rows 7 -width 32 -l 1 \
-hide-scrollbar -eh 1 -location 0 -padding 12 -opacity 100)"
/home/jpm/scripts/send-to-kodi.sh $INPUT 2>&1 /dev/null

View File

@ -1,6 +1,11 @@
#!/bin/bash
res=$(echo "john.me.tz|root@john.me.tz|t470s.lan.john.me.tz|shb.ng|kipary.mailcleaner.net|media.lan.john.me.tz|pipcam.lan.john.me.tz|therm.lan.john.me.tz|hud.lan.john.me.tz|vm.lan.john.me.tz" | rofi -sep "|" -dmenu -i -p 'P ' "" -columns 1 -rows 1 -width 45 -l 1 -config /home/jpm/.config/rofi/config -hide-scrollbar -eh 1 -location 0 -yoffset 0 -padding 12 -opacity 100 -auto-select -no-fullscreen)
res=$(echo "john.me.tz|root@john.me.tz|t470s.lan.john.me.tz|shb.ng|\
kipary.mailcleaner.net|media.lan.john.me.tz|pipcam.lan.john.me.tz|\
therm.lan.john.me.tz|hud.lan.john.me.tz|vm.lan.john.me.tz" | \
rofi -sep "|" -dmenu -i -p 'P ' "" -columns 1 -rows 1 -width 45 -l 1 -config \
/home/jpm/.config/rofi/config -hide-scrollbar -eh 1 -location 0 -yoffset 0 \
-padding 12 -opacity 100 -auto-select -no-fullscreen)
if [ $res = "john.me.tz" ]; then
/usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs w'

View File

@ -61,7 +61,8 @@ ytplugin='plugin://plugin.video.youtube/?action=play_video&videoid='
# Dialog box?
input=$1
until [[ $input ]]; do
input="$(zenity --entry --title "Send to Kodi" --text "Paste a video link here")" || exit
input="$(zenity --entry --title "Send to Kodi" --text \
"Paste a video link here")" || exit
done
if [[ $input =~ ^file:// ]]; then
@ -74,7 +75,8 @@ fi
# Local media
if [[ -e $input ]]; then
type nc &>/dev/null || error "netcat required"
[[ $local_hostname && $local_port ]] || error "Please set local hostname and port in configuration"
[[ $local_hostname && $local_port ]] || \
error "Please set local hostname and port in configuration"
# Start netcat in background and kill it when we exit
nc -lp $local_port < "$input" &
@ -84,7 +86,10 @@ if [[ -e $input ]]; then
# youtube.com / youtu.be
elif [[ $input =~ ^https?://(www\.)?youtu(\.be/|be\.com/watch\?v=) ]]; then
url="$ytplugin$(sed 's/.*\(youtu\.be\/\|[&?]v=\)\([a-zA-Z0-9_-]\+\).*/\2/' <<< "$input")"
url="$ytplugin$(\
sed 's/.*\(youtu\.be\/\|[&?]v=\)\([a-zA-Z0-9_-]\+\).*/\2/'\
<<< "$input"\
)"
# Playable formats
elif [[ $input =~ \.(mp4|mkv|mov|avi|flv|wmv|asf|mp3|flac|mka|m4a|aac|ogg|pls|jpg|png|gif|jpeg|tiff)(\?.*)?$ ]]; then
@ -93,7 +98,8 @@ elif [[ $input =~ \.(mp4|mkv|mov|avi|flv|wmv|asf|mp3|flac|mka|m4a|aac|ogg|pls|jp
# Youtube-dl
else
type youtube-dl &>/dev/null || error "youtube-dl required"
url="$(youtube-dl -gf best "$input")" || error "No videos found, or site not supported by youtube-dl"
url="$(youtube-dl -gf best "$input")" || \
error "No videos found, or site not supported by youtube-dl"
fi
[[ $url ]] && send_json "$url"

View File

@ -171,7 +171,8 @@ if (scalar(@ARGV)) {
# Get previous config if one is not provided
unless (defined $config) {
open(my $fh, '<', $last) || die "Config name not provided and failed to open $last\n";
open(my $fh, '<', $last) ||
die "Config name not provided and failed to open $last\n";
$config = <$fh>;
close($fh);
chomp $config;
@ -179,11 +180,13 @@ unless (defined $config) {
# Bail if requested config doesn't exist
unless (defined $configs{$config}) {
die "$config is not a defined configuration: " . join(', ', keys %configs) . "\n";
die "$config is not a defined configuration: "
. join(', ', keys %configs) . "\n";
}
# Write config that is to be used so that it can be recovered as default
open(my $fh, '>', $last) || print STDERR "Config name cannot be written to $last\n";
open(my $fh, '>', $last) ||
print STDERR "Config name cannot be written to $last\n";
print $fh $config;
close($fh);
@ -199,17 +202,21 @@ my $on;
my @off;
for (my $i = 0; $i < scalar(@$displays); $i++) {
# If a display is found without any settings, print error and turn it off
# If a display is found without any settings print error and turn it off
unless (defined $configs{$config}{$outputs{$displays->[$i]->{serial}}}){
print STDERR "Output $displays->[$i]->{name} ($displays->[$i]->{serial}) found without defined function. Disabling.\n";
print STDERR "Output $displays->[$i]->{name} ("
. $displays->[$i]->{serial}
. ") found without defined function. Disabling.\n";
push @off, $displays->[$i]->{name};
next;
}
# If display is enabled, copy all of the desired settings
if ($configs{$config}{$outputs{$displays->[$i]->{serial}}}{on}) {
$on->{$outputs{$displays->[$i]->{serial}}} = $configs{$config}{$outputs{$displays->[$i]->{serial}}};
$on->{$outputs{$displays->[$i]->{serial}}}{output} = $displays->[$i]->{name};
$on->{$outputs{$displays->[$i]->{serial}}} =
$configs{$config}{$outputs{$displays->[$i]->{serial}}};
$on->{$outputs{$displays->[$i]->{serial}}}{output} =
$displays->[$i]->{name};
# Otherwise simply list it for disabling
} else {
push @off, $displays->[$i]->{name};
@ -219,7 +226,8 @@ for (my $i = 0; $i < scalar(@$displays); $i++) {
# Skip enabling/disabling displays if only running waybar (re)start
unless ($waybar_only) {
# Number of simultaneous outputs is limited by gpu, so disabled displays first
# Number of simultaneous outputs is limited by gpu, so disabled displays
# first
foreach (@off) {
# Sway returns status as JSON
@ -228,7 +236,8 @@ unless ($waybar_only) {
# If failed, print to STDERR
unless ($res->{success}) {
print STDERR "Error ($res->{error}) in command 'sway output $_ disable'\n";
print STDERR "Error ($res->{error}) in command 'sway"
. "output $_ disable'\n";
}
}
@ -244,8 +253,6 @@ foreach my $p ( @{ $t->table } ) {
# Never kill this process
if ($p->{'pid'} == $$) {
next;
# SIGKILL match
# TODO BUG: when multiple processes are running, some respawn with new PIDs. IDK why?
} else {
$p->kill(9);
}
@ -264,7 +271,8 @@ if (open (my $fh, '<', $waybar_template)) {
print STDERR "Failed to load template $waybar_template\n";
}
# If template is already set up as an array, remove the square brackets so that we can concatenate multiple displays
# If template is already set up as an array, remove the square brackets so that
# we can concatenate multiple displays
$template =~ s/^[^\[\{]*\[(.*)\]$/$1/s;
# Setup waybar config file
@ -284,7 +292,9 @@ foreach my $out (keys %$on) {
if (defined $on->{$out}->{x} && defined $on->{$out}->{y}) {
$cmd .= " position $on->{$out}->{x} $on->{$out}->{y}";
}
if (defined $on->{$out}->{width} && defined $on->{$out}->{height}) {
if (defined $on->{$out}->{width} &&
defined $on->{$out}->{height} )
{
$cmd .= " mode $on->{$out}->{width}x$on->{$out}->{height}";
}
@ -299,7 +309,10 @@ foreach my $out (keys %$on) {
}
# Skip waybar setup if template failed to be loaded
if ( (defined $template) && (defined $on->{$out}->{waybar}) && ($on->{$out}->{waybar} =~ m/(top|bottom|left|right)/) ) {
if ( (defined $template) &&
(defined $on->{$out}->{waybar}) &&
($on->{$out}->{waybar} =~ m/(top|bottom|left|right)/) )
{
# If there's already a display set up, add a comma
unless ($waybar eq '') {

View File

@ -23,7 +23,8 @@ unless ($pid) {
`gammastep -l $lat_lon`;
}
sub fetch_lat_lon {
sub fetch_lat_lon
{
my ($ua, $json, $location) = @_;
my $raw = $ua->get($location)->content();

View File

@ -19,10 +19,12 @@ my $root = $json->decode($raw);
my $display = $root->{focus}->[0];
my ($workspace, $term_id, $term_ws);
foreach my $d (@{$root->{nodes}}) {
# If both the current workspace and terminal have been found, nothing else to look for
# If both the current workspace and terminal have been found
# nothing else to look for
if (defined($workspace) && defined($term_id)) {
last;
# If the display from this iteration of the loop is in focus, look for the active workspace
# If the display from this iteration of the loop is in focus
# look for the active workspace
} elsif ($d->{id} eq $display) {
foreach my $w (@{$d->{nodes}}) {
# Again, if both found, skip
@ -57,13 +59,15 @@ foreach my $d (@{$root->{nodes}}) {
}
}
}
print "Active workspace = $workspace\nTerminal ID = $term_id\nTerminal WS = $term_ws\n";
print "Active workspace = $workspace\n"
. "Terminal ID = $term_id\n"
. "Terminal WS = $term_ws\n";
# If there is no terminal found, spawn one
if (!defined($term_id)) {
print "No term running, starting one\n";
exec $term
# If the current workspace is known and terminal isn't on it, bring and give focus
# If the current workspace is known and terminal isn't on it, bring and focus
} elsif ($workspace != $term_ws) {
print "Term not on current workspace, bringing it\n";
`swaymsg "[con_id=$term_id]" move workspace $workspace`;

View File

@ -3,9 +3,12 @@
BLFILE="/tmp/blc"
if [ -z $1 ]; then
echo "Missing argument: swayidlerun, swayidlewarn, swayidlesleep or swayidlewake"
echo "Missing argument: swayidlerun, swayidlewarn, swayidlesleep or" \
" swayidlewake"
elif [ $1 == "swayidlerun" ]; then
swayidle timeout 270 "/home/jpm/scripts/swayidle.sh swayidlewarn" before-sleep "/home/jpm/scripts/swayidle.sh swayidlesleep" resume "/home/jpm/scripts/swayidle.sh swayidlewake"
swayidle timeout 270 "/home/jpm/scripts/swayidle.sh swayidlewarn" \
before-sleep "/home/jpm/scripts/swayidle.sh swayidlesleep" \
resume "/home/jpm/scripts/swayidle.sh swayidlewake"
elif [ $1 == "swayidlewarn" ]; then
# Store current brightness
echo $(/home/jpm/bin/blc.pl %) > $BLFILE
@ -15,7 +18,8 @@ elif [ $1 == "swayidlewarn" ]; then
/home/jpm/scripts/swayidlecountdown.sh
elif [ $1 == "swayidlesleep" ]; then
# Change nick to AFK
ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t 'screen -S irssi -X stuff "/nick jpmAFK^M"'
ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
'screen -S irssi -X stuff "/nick jpmAFK^M"'
# Turn off monitor
swaymsg 'swaymsg "output * dpms off"'
# Lock screen

View File

@ -5,7 +5,8 @@ my $cur_file = "/sys/class/backlight/intel_backlight/brightness";
my $max_file = "/sys/class/backlight/intel_backlight/max_brightness";
my $last_file = "/home/jpm/.config/blc.last";
sub to_percent {
sub to_percent
{
my $value = shift;
if ($value eq "Permission Denied") {
return $value;
@ -15,11 +16,13 @@ sub to_percent {
}
}
sub get_offset {
sub get_offset
{
return int(get_max()/100);
}
sub get_current {
sub get_current
{
open(my $c,'<',"$cur_file");
my $current = <$c>;
close $c;
@ -27,7 +30,8 @@ sub get_current {
return $current;
}
sub get_max {
sub get_max
{
open(my $m,'<',"$max_file");
my $max = <$m>;
close $m;
@ -35,11 +39,13 @@ sub get_max {
return $max;
}
sub get_min {
sub get_min
{
return int((get_max()/100)+2);
}
sub writable {
sub writable
{
if (! -w $cur_file) {
return 0;
} else {
@ -47,7 +53,8 @@ sub writable {
}
}
sub increment {
sub increment
{
if (writable()) {
my $current = get_current();
my $max = get_max();
@ -64,7 +71,8 @@ sub increment {
}
}
sub decrement {
sub decrement
{
if (writable()) {
my $current = get_current();
my $min = get_min();
@ -81,7 +89,8 @@ sub decrement {
}
}
sub set {
sub set
{
my $value = shift;
if (writable()) {
$current = get_current();
@ -104,7 +113,8 @@ sub set {
}
}
sub help {
sub help
{
print "
Backlight Control
@ -146,7 +156,8 @@ Print:
Any other option will be printed literally";
}
sub advanced {
sub advanced
{
$current = get_current();
$max = get_max();
print ".
@ -189,13 +200,15 @@ if (scalar @ARGV) {
$count = $ARGV[($i+1)];
for (my $j=0;$j<$count;$j++) {
$target = increment();
if ($target eq "Permission Denied") {
if ($target eq
"Permission Denied") {
last;
}
}
@output = to_percent($target);
} else {
@output = ("No value after $ARGV[$i]");
@output =
("No value after $ARGV[$i]");
}
last;
}
@ -212,13 +225,15 @@ if (scalar @ARGV) {
$count = $ARGV[($i+1)];
for (my $j=0;$j<$count;$j++) {
$target = decrement();
if ($target eq "Permission Denied") {
if ($target eq
"Permission Denied") {
last;
}
}
@output = to_percent($target);
} else {
@output = ("No value after $ARGV[$i]");
@output =
("No value after $ARGV[$i]");
}
last;
}
@ -234,7 +249,9 @@ if (scalar @ARGV) {
} elsif ($target > 100) {
$target = set($target);
} else {
$target = set(int((get_max()*$target/100)+1));
$target = set(
int((get_max()*$target/100)+1)
);
}
if ($target eq "Permission Denied") {
@output = $target;
@ -277,7 +294,15 @@ if (scalar @ARGV) {
}
}
} else {
@output = ('{"Backlight":{"Max":"' . get_max() . '","Current":"' . get_current() . '","Percentage","' . int(get_current()/get_max()*100) . '%"}}');
@output = (
'{"Backlight":{"Max":"'
. get_max()
. '","Current":"'
. get_current()
. '","Percentage","'
. int(get_current()/get_max()*100)
. '%"}}'
);
}
@ -296,7 +321,13 @@ if ($silent) {
foreach (@output) {
$concat .= $_;
}
system "notify-send --urgency=normal -i /usr/share/icons/Papirus-Dark-Grey/48x48/status/notification-display-brightness.svg -t $duration \"$concat\"";
system "notify-send --urgency=normal -i "
. "/usr/share/icons/Papirus-Dark-Grey/48x48/status/"
. "notification-display-brightness.svg -t "
. $duration
. ' "'
. $concat
. '"';
exit();
} else {
print foreach @output;

View File

@ -2,7 +2,9 @@
Description=Give ownership of backlight to %I
[Service]
ExecStart=chown %i:%i /sys/class/backlight/intel_backlight/brightness /sys/class/leds/tpacpi::kbd_backlight/brightness
ExecStart=chown %i:%i \
/sys/class/backlight/intel_backlight/brightness \
/sys/class/leds/tpacpi::kbd_backlight/brightness
[Install]
WantedBy=multi-user.target

View File

@ -11,11 +11,13 @@ my $install = "$ENV{HOME}/.local/bin";
my $working = "/tmp/firefox.new";
# Download link as provided by https://www.mozilla.org/$lang/firefox/developer/
my $url = 'https://download.mozilla.org/?product=firefox-devedition-latest-ssl&os=linux64&lang='.$lang;
my $url = 'https://download.mozilla.org/?product=firefox-devedition-latest-ssl'
. '&os=linux64&lang='.$lang;
# Ensure that we can unzip
unless (which("bunzip2")) {
die "Requires bunzip2. Try:\nsudo apt install zutils or your distro's equivalent\n";
die "Requires bunzip2. Try:\n"
. "sudo apt install zutils or your distro's equivalent\n";
}
# Only understood argument is to not bother verifying the package
@ -33,7 +35,12 @@ unless ($verify) {
print "Checking for Mozilla GPG key in keyring...\n";
system("gpg --list-keys release\@mozillla.com 2>&1 > /dev/null");
if ($?) {
my $YN = prompt (-in => *STDIN, "You don't currently have Mozilla's GPG key in your keyring.\nWould you like to install it? If not, installation will not be verified. [y/N]: ", -single);
my $YN = prompt (-in => *STDIN, "You don't currently have "
. "Mozilla's GPG key in your keyring.\n"
. "Would you like to install it? If not, installation "
. "will not be verified. [y/N]: ",
-single
);
if ($YN eq 'y' || $YN eq 'Y') {
$download_key = 1;
} else {
@ -46,7 +53,9 @@ unless ($verify) {
if ( -e $working ) {
system("rm -rf $working");
if ($?) {
die "Working directory $working already exists and failed to remove: $!\n";
die "Working directory "
. $working
. "already exists and failed to remove: $!\n";
}
}
@ -58,11 +67,13 @@ chomp $current;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
# $url is actually going to redirect to the proper current dowload, so just get the redirect.
# $url is actually going to redirect to the proper current dowload so just get
# the redirect.
my $head = $mech->head($url);
my ($location, $version);
# This redirect will have the version id, so we can use that to determine if a new version actually exists
# This redirect will have the version id, so we can use that to determine if a
# new version actually exists
if ($head->{'_msg'}) {
$version = $location = $head->{'_previous'}->{'_headers'}->{'location'};
$version =~ s/^.*\-([^\-]*)\.tar\.bz2$/$1/;
@ -78,14 +89,20 @@ mkdir($working) || die "Couldn't make $working: $!\n";
# Download package
print "Fetching package $location...\n";
$mech->get($location);
$mech->save_content( $working."/firefox-".$version.".tar.bz2", binmode => ':raw', decoded_by_headers => 1 );
$mech->save_content( $working."/firefox-".$version.".tar.bz2",
binmode => ':raw',
decoded_by_headers => 1
);
# If verification is required, get signature as well
if ($verify) {
$location .= '.asc';
print "Fetching GPG signature $location...\n";
$mech->get($location);
$mech->save_content( $working."/firefox-".$version.".tar.bz2.asc", binmode => ':raw', decoded_by_headers => 1 );
$mech->save_content( $working."/firefox-".$version.".tar.bz2.asc",
binmode => ':raw',
decoded_by_headers => 1
);
}
# If key still needs to be fetched, get it
@ -93,12 +110,22 @@ if ($download_key) {
$location =~ s/linux-x86_64.*$/KEY/;
print "Fetching GPG key $location...\n";
$mech->get($location);
$mech->save_content( $working."/mozilla.pgp", binmode => ':raw', decoded_by_headers => 1 );
$mech->save_content( $working."/mozilla.pgp",
binmode => ':raw',
decoded_by_headers => 1
);
# And install it
print "Installing Mozilla GPG key in keyring...\n";
system("gpg --import $working/mozilla.pgp 2>&1 > /dev/null");
if ($?) {
die "Warning: failed to import key. Cannot verify integrity.\nDownloaded to $working. You can check and install it to $install manually: $!\n";
die "Warning: failed to import key. Cannot verify integrity.\n"
. "Downloaded to "
. $working
. ". You can check and install it to "
. $install
. "manually: "
. $!
. "\n";
}
unlink("$working/mozilla.pgp");
}
@ -108,7 +135,14 @@ if ($verify) {
print "Verifying download with Mozilla GPG key...\n";
system("gpg --verify $working/firefox-$version.tar.bz2.asc");
if ($?) {
die "Warning: failed to verify download. Signing failed.\nDownloaded to $working. You can check and install it to $install manually: $!\n";
die "Warning: failed to verify download. Signing failed.\n"
. "Downloaded to "
. $working
. ". You can check and install it to "
. $install
. " manually: "
. $!
. "\n";
}
}
@ -136,7 +170,11 @@ if (-e "$install/.firefox.old") {
}
# Move current to old
print "Backing up currently installed version ($current) to $install/.firefox.old...\n";
print "Backing up currently installed version ("
. $current
. ") to "
. $install
. "/.firefox.old...\n";
system("mv $install/firefox $install/.firefox.old");
if ($?) {
die "Failed to move: $!\n";
@ -150,5 +188,7 @@ if ($?) {
}
# Hurray!
print "Installation of version $version complete. You should restart firefox whenever it is convenient.\n";
print "Installation of version "
. $version
. " complete. You should restart firefox whenever it is convenient.\n";
exit();

View File

@ -1,3 +1,7 @@
#!/bin/bash
notify-send -t 3000 Disks "$(lsblk -o NAME,SIZE,FSUSE%,MOUNTPOINT | grep -vP '^loop' | sed 's/MOUNTPOINT/MOUNT/' | sed -e 's/│ └─/+---/' | sed -e 's/ └─/+---/' | sed -e 's/├─/+-/' | sed -e 's/└─/+-/' | awk {'printf "%-20s %-7s %- 6s %-7s\n", $1, $2, $3, $4'})"
notify-send -t 3000 Disks \
"$(lsblk -o NAME,SIZE,FSUSE%,MOUNTPOINT | grep -vP '^loop' | \
sed 's/MOUNTPOINT/MOUNT/' | sed -e 's/│ └─/+---/' | \
sed -e 's/ └─/+---/' | sed -e 's/├─/+-/' | sed -e 's/└─/+-/' | \
awk {'printf "%-20s %-7s %- 6s %-7s\n", $1, $2, $3, $4'})"

View File

@ -1,3 +1,5 @@
#!/bin/bash
notify-send 'Memory Usage' "`free -h | awk '{printf(\"%6s %6s %6s %6s\n\", $1, $2, $3, $4)}' | sed -r 's/(.*) shared$/ \1/'`"
notify-send 'Memory Usage' "`free -h | \
awk '{printf(\"%6s %6s %6s %6s\n\", $1, $2, $3, $4)}' | \
sed -r 's/(.*) shared$/ \1/'`"