Browse Source

a couple of new scripts and fixes, fix for keyboard layouts on lock screen

Von Random 1 year ago
parent
commit
6c22f6be55
5 changed files with 108 additions and 1 deletions
  1. 1
    1
      dmenu_ssh
  2. 2
    0
      lock-screen
  3. 6
    0
      mykblayouts
  4. 96
    0
      print256colours.sh
  5. 3
    0
      tweechat

+ 1
- 1
dmenu_ssh View File

@@ -1,7 +1,7 @@
1 1
 #!/bin/sh
2 2
 
3 3
 export SSH_AUTH_SOCK="${HOME}/.ssh/ssh_auth_sock"
4
-cmd=$1
4
+cmd="$1"
5 5
 shift
6 6
 get_hosts() {
7 7
     awk -F",| " '{print $1}' "${HOME}/.ssh/known_hosts"

+ 2
- 0
lock-screen View File

@@ -3,6 +3,8 @@ BACKGROUND='/tmp/screen_locked.png'
3 3
 notify-send DUNST_COMMAND_PAUSE
4 4
 scrot $BACKGROUND
5 5
 mogrify -scale 10% -colorspace GRAY -scale 1000% $BACKGROUND
6
+setxkbmap -layout us -variant altgr-intl
6 7
 until i3lock -entc 661111 -i $BACKGROUND; do :; done
8
+mykblayouts
7 9
 rm $BACKGROUND
8 10
 notify-send DUNST_COMMAND_RESUME

+ 6
- 0
mykblayouts View File

@@ -0,0 +1,6 @@
1
+#!/usr/bin/env zsh
2
+layouts='us,ru'
3
+variants='altgr-intl,typewriter'
4
+opts='ctrl:nocaps,grp:win_space_toggle,compose:menu'
5
+
6
+setxkbmap -layout $layouts -variant $variants -option $opts

+ 96
- 0
print256colours.sh View File

@@ -0,0 +1,96 @@
1
+#!/bin/bash
2
+
3
+# Tom Hale, 2016. MIT Licence.
4
+# Print out 256 colours, with each number printed in its corresponding colour
5
+# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163
6
+
7
+set -eu # Fail on errors or undeclared variables
8
+
9
+printable_colours=256
10
+
11
+# Return a colour that contrasts with the given colour
12
+# Bash only does integer division, so keep it integral
13
+function contrast_colour {
14
+    local r g b luminance
15
+    colour="$1"
16
+
17
+    if (( colour < 16 )); then # Initial 16 ANSI colours
18
+        (( colour == 0 )) && printf "15" || printf "0"
19
+        return
20
+    fi
21
+
22
+    # Greyscale # rgb_R = rgb_G = rgb_B = (number - 232) * 10 + 8
23
+    if (( colour > 231 )); then # Greyscale ramp
24
+        (( colour < 244 )) && printf "15" || printf "0"
25
+        return
26
+    fi
27
+
28
+    # All other colours:
29
+    # 6x6x6 colour cube = 16 + 36*R + 6*G + B  # Where RGB are [0..5]
30
+    # See http://stackoverflow.com/a/27165165/5353461
31
+
32
+    # r=$(( (colour-16) / 36 ))
33
+    g=$(( ((colour-16) % 36) / 6 ))
34
+    # b=$(( (colour-16) % 6 ))
35
+
36
+    # If luminance is bright, print number in black, white otherwise.
37
+    # Green contributes 587/1000 to human perceived luminance - ITU R-REC-BT.601
38
+    (( g > 2)) && printf "0" || printf "15"
39
+    return
40
+
41
+    # Uncomment the below for more precise luminance calculations
42
+
43
+    # # Calculate percieved brightness
44
+    # # See https://www.w3.org/TR/AERT#color-contrast
45
+    # # and http://www.itu.int/rec/R-REC-BT.601
46
+    # # Luminance is in range 0..5000 as each value is 0..5
47
+    # luminance=$(( (r * 299) + (g * 587) + (b * 114) ))
48
+    # (( $luminance > 2500 )) && printf "0" || printf "15"
49
+}
50
+
51
+# Print a coloured block with the number of that colour
52
+function print_colour {
53
+    local colour="$1" contrast
54
+    contrast=$(contrast_colour "$1")
55
+    printf "\e[48;5;%sm" "$colour"                # Start block of colour
56
+    printf "\e[38;5;%sm%3d" "$contrast" "$colour" # In contrast, print number
57
+    printf "\e[0m "                               # Reset colour
58
+}
59
+
60
+# Starting at $1, print a run of $2 colours
61
+function print_run {
62
+    local i
63
+    for (( i = "$1"; i < "$1" + "$2" && i < printable_colours; i++ )) do
64
+        print_colour "$i"
65
+    done
66
+    printf "  "
67
+}
68
+
69
+# Print blocks of colours
70
+function print_blocks {
71
+    local start="$1" i
72
+    local end="$2" # inclusive
73
+    local block_cols="$3"
74
+    local block_rows="$4"
75
+    local blocks_per_line="$5"
76
+    local block_length=$((block_cols * block_rows))
77
+
78
+    # Print sets of blocks
79
+    for (( i = start; i <= end; i += (blocks_per_line-1) * block_length )) do
80
+        printf "\n" # Space before each set of blocks
81
+        # For each block row
82
+        for (( row = 0; row < block_rows; row++ )) do
83
+            # Print block columns for all blocks on the line
84
+            for (( block = 0; block < blocks_per_line; block++ )) do
85
+                print_run $(( i + (block * block_length) )) "$block_cols"
86
+            done
87
+            (( i += block_cols )) # Prepare to print the next row
88
+            printf "\n"
89
+        done
90
+    done
91
+}
92
+
93
+print_run 0 16 # The first 16 colours are spread over the whole spectrum
94
+printf "\n"
95
+print_blocks 16 231 6 6 3 # 6x6x6 colour cube between 16 and 231 inclusive
96
+print_blocks 232 255 12 2 1 # Not 50, but 24 Shades of Grey

+ 3
- 0
tweechat View File

@@ -0,0 +1,3 @@
1
+#!/usr/bin/env bash
2
+term=default-terminal-emulator
3
+exec $term -e weechat

Loading…
Cancel
Save