Adds basic xrandr
This commit is contained in:
parent
1d983ddf30
commit
781052e508
|
@ -6,6 +6,7 @@ source ~/.config/nushell/config/update.nu
|
||||||
source ~/.config/nushell/config/gclone.nu
|
source ~/.config/nushell/config/gclone.nu
|
||||||
source ~/.config/nushell/config/pass.nu
|
source ~/.config/nushell/config/pass.nu
|
||||||
source ~/.config/nushell/config/docker.nu
|
source ~/.config/nushell/config/docker.nu
|
||||||
|
source ~/.config/nushell/config/xrandr.nu
|
||||||
|
|
||||||
# Start tfetch
|
# Start tfetch
|
||||||
tfetch
|
tfetch
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
# nushell-ify xrandr
|
||||||
|
def xrandr [] {
|
||||||
|
mut output = []
|
||||||
|
mut current_screen: record<name: string, connected: bool, resolutions: list<string>> = {
|
||||||
|
name: ""
|
||||||
|
connected: false
|
||||||
|
resolutions: []
|
||||||
|
}
|
||||||
|
|
||||||
|
let lines = ^xrandr | lines
|
||||||
|
let length = $lines | length
|
||||||
|
|
||||||
|
# We skip the first line
|
||||||
|
for i in 1..<$length {
|
||||||
|
|
||||||
|
let line = $lines | get $i
|
||||||
|
let split = $line | split row -r '\s+'
|
||||||
|
|
||||||
|
# This will be true whether the screen is connected or not
|
||||||
|
if $line =~ "connected" {
|
||||||
|
|
||||||
|
if $current_screen.name != "" {
|
||||||
|
$output = ($output | append $current_screen)
|
||||||
|
}
|
||||||
|
|
||||||
|
$current_screen.name = (echo $split | get 0)
|
||||||
|
$current_screen.connected = ((echo $split | get 1) != "disconnected")
|
||||||
|
$current_screen.resolutions = []
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$current_screen.resolutions = ($current_screen.resolutions | append ($split | get 1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if $current_screen.name != "" {
|
||||||
|
$output = ($output | append $current_screen)
|
||||||
|
}
|
||||||
|
|
||||||
|
$output
|
||||||
|
}
|
Loading…
Reference in New Issue