Compare commits
10 Commits
27dfd2fd2e
...
b556ef9551
| Author | SHA1 | Date | |
|---|---|---|---|
| b556ef9551 | |||
| 426fe32a63 | |||
| 624032f2fb | |||
| 1708c3ca21 | |||
| d5fda9750b | |||
| 89e34ddb3b | |||
| c0c947c548 | |||
| 5c43b86914 | |||
| 59cf0822aa | |||
| 4f6d0b6035 |
Binary file not shown.
|
After Width: | Height: | Size: 4.7 MiB |
+2
-4
@@ -90,9 +90,8 @@ if ${use_color} ; then
|
||||
PS1+='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
|
||||
fi
|
||||
|
||||
#BSD#@export CLICOLOR=1
|
||||
#GNU#@alias ls='ls --color=auto'
|
||||
alias grep='grep --colour=auto'
|
||||
alias ls='ls --color=auto'
|
||||
else
|
||||
# show root@ when we don't have colors
|
||||
PS1+='\u@\h \w \$ '
|
||||
@@ -109,8 +108,7 @@ fi
|
||||
# Try to keep environment pollution down, EPA loves us.
|
||||
unset use_color sh
|
||||
|
||||
alias ls='ls --color=auto'
|
||||
alias grep='grep --color=auto'
|
||||
alias ff='fastfetch'
|
||||
. "$HOME/.cargo/env"
|
||||
|
||||
eval "$(starship init bash)"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
# #######################################################################################
|
||||
# AUTOGENERATED HYPRLAND CONFIG.
|
||||
# PLEASE USE THE CONFIG PROVIDED IN THE GIT REPO /examples/hyprland.conf AND EDIT IT,
|
||||
@@ -37,9 +36,9 @@ $terminal = kitty
|
||||
$fileManager = dolphin
|
||||
$menu = tofi-drun --drun-launch=true
|
||||
$colorPicker = hyprpicker -a
|
||||
$screenshot = /home/chips/.local/bin/grimblast copy area
|
||||
$browser = brave
|
||||
|
||||
|
||||
#################
|
||||
### AUTOSTART ###
|
||||
#################
|
||||
@@ -51,20 +50,17 @@ exec-once = waybar
|
||||
exec-once = sway-nc
|
||||
exec-once = systemctl --user start hyprpolkitagent
|
||||
exec-once = hyprpaper
|
||||
# exec-once = nm-applet &
|
||||
# exec-once = waybar & hyprpaper & firefox
|
||||
|
||||
#exec-once = $terminal
|
||||
#exec-once = hyprctl dispatch workspace 3
|
||||
|
||||
#############################
|
||||
### ENVIRONMENT VARIABLES ###
|
||||
#############################
|
||||
|
||||
# See https://wiki.hyprland.org/Configuring/Environment-variables/
|
||||
|
||||
env = XCURSOR_SIZE,24
|
||||
env = HYPRCURSOR_SIZE,24
|
||||
|
||||
|
||||
#####################
|
||||
### LOOK AND FEEL ###
|
||||
#####################
|
||||
@@ -97,8 +93,8 @@ decoration {
|
||||
rounding_power = 3
|
||||
|
||||
# Change transparency of focused and unfocused windows
|
||||
active_opacity = 0.95
|
||||
inactive_opacity = 0.9
|
||||
active_opacity = 1
|
||||
inactive_opacity = 1
|
||||
fullscreen_opacity = 1
|
||||
|
||||
shadow {
|
||||
@@ -157,10 +153,6 @@ animations {
|
||||
# windowrule = bordersize 0, floating:0, onworkspace:f[1]
|
||||
# windowrule = rounding 0, floating:0, onworkspace:f[1]
|
||||
|
||||
windowrule = workspace 10,title:(.*)MOVE TO WORKSPACE 10(.*)
|
||||
windowrule = center,title:(.*)MOVE TO WORKSPACE 10(.*)
|
||||
windowrule = size 800 500,title:(.*)MOVE TO WORKSPACE 10(.*)
|
||||
|
||||
workspace = 1, monitor:DP-1, default:true, persistent:true
|
||||
workspace = 2, monitor:DP-1, default:true, persistent:true
|
||||
workspace = 3, monitor:DP-1, default:true, persistent:true
|
||||
@@ -209,11 +201,6 @@ input {
|
||||
}
|
||||
}
|
||||
|
||||
# https://wiki.hyprland.org/Configuring/Variables/#gestures
|
||||
gestures {
|
||||
workspace_swipe = false
|
||||
}
|
||||
|
||||
# Example per-device config
|
||||
# See https://wiki.hyprland.org/Configuring/Keywords/#per-device-input-configs for more
|
||||
device {
|
||||
@@ -237,10 +224,11 @@ bind = $mainMod, F, fullscreen,
|
||||
# bind = $mainMod, M, exit,
|
||||
bind = $mainMod, E, exec, $fileManager
|
||||
bind = $mainMod, C, exec, $colorPicker
|
||||
bind = $mainMod, S, exec, $screenshot
|
||||
bind = $mainMod, B, exec, $browser
|
||||
# bind = $mainMod, V, togglefloating,
|
||||
bind = $mainMod, T, togglefloating,
|
||||
bind = $mainMod, R, exec, $menu
|
||||
bind = $mainMod, P, pseudo, # dwindle
|
||||
# bind = $mainMod, P, pseudo, # dwindle
|
||||
# bind = $mainMod, J, togglesplit, # dwindle
|
||||
bind = $mainMod, Q, exec, hyprlock
|
||||
bind = $mainMod SHIFT, Q, exec, dm-tool switch-to-greeter
|
||||
@@ -276,8 +264,8 @@ bind = $mainMod SHIFT, 9, movetoworkspace, 9
|
||||
bind = $mainMod SHIFT, 0, movetoworkspace, 10
|
||||
|
||||
# Example special workspace (scratchpad)
|
||||
bind = $mainMod, S, togglespecialworkspace, magic
|
||||
bind = $mainMod SHIFT, S, movetoworkspace, special:magic
|
||||
# bind = $mainMod, S, togglespecialworkspace, magic
|
||||
# bind = $mainMod SHIFT, S, movetoworkspace, special:magic
|
||||
|
||||
# Volume keys
|
||||
bindel = $mainMod, V , exec, pactl set-sink-volume @DEFAULT_SINK@ -5%
|
||||
@@ -308,7 +296,34 @@ bind = $mainMod CTRL, L, exec, sleep 1 && hyprctl dispatch dpms toggle HDMI-A-1
|
||||
# windowrule = float,class:^(kitty)$,title:^(kitty)$
|
||||
|
||||
# Ignore maximize requests from apps. You'll probably like this.
|
||||
windowrule = suppressevent maximize, class:.*
|
||||
windowrule {
|
||||
# Ignore maximize requests from all apps. You'll probably like this.
|
||||
name = suppress-maximize-events
|
||||
match:class = .*
|
||||
|
||||
suppress_event = maximize
|
||||
}
|
||||
|
||||
windowrule {
|
||||
name = debug-builds
|
||||
match:title = .*Debug:.*
|
||||
|
||||
center = on
|
||||
workspace = 10
|
||||
size = 900 900
|
||||
float = yes
|
||||
}
|
||||
|
||||
# Fix some dragging issues with XWayland
|
||||
windowrule = nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0
|
||||
windowrule {
|
||||
# Fix some dragging issues with XWayland
|
||||
name = fix-xwayland-drags
|
||||
match:class = ^$
|
||||
match:title = ^$
|
||||
match:xwayland = true
|
||||
match:float = true
|
||||
match:fullscreen = false
|
||||
match:pin = false
|
||||
|
||||
no_focus = true
|
||||
}
|
||||
|
||||
@@ -1,2 +1,14 @@
|
||||
preload = /home/chips/Pictures/wallpapers/summer_dreams.png
|
||||
wallpaper =, /home/chips/Pictures/wallpapers/summer_dreams.png
|
||||
ipc = off
|
||||
splash = off
|
||||
|
||||
wallpaper {
|
||||
monitor = HDMI-A-1
|
||||
path = /home/chips/Pictures/wallpapers/summer_dreams.png
|
||||
fit_mode = cover
|
||||
}
|
||||
|
||||
wallpaper {
|
||||
monitor = DP-1
|
||||
path = /home/chips/Pictures/wallpapers/wallhaven-1.jpg
|
||||
fit_mode = cover
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# vim:ft=kitty
|
||||
## name: Nord
|
||||
## author: Eric N. Vander Weele
|
||||
## upstream: https://www.nordtheme.com/
|
||||
## blurb: Nord theme utilizing the full Frost and Aurora palette.
|
||||
|
||||
# Basic colors
|
||||
foreground #d8dee9
|
||||
background #2e3440
|
||||
selection_foreground #d8dee9
|
||||
selection_background #434c5e
|
||||
|
||||
# Cursor colors
|
||||
cursor #d8dee9
|
||||
cursor_text_color #3b4252
|
||||
|
||||
# URL underline color when hovering with mouse
|
||||
url_color #0087bd
|
||||
|
||||
# Window border colors and terminal bell colors
|
||||
active_border_color #81a1c1
|
||||
inactive_border_color #4c566a
|
||||
bell_border_color #88c0d0
|
||||
visual_bell_color none
|
||||
|
||||
# Tab bar colors
|
||||
active_tab_foreground #3b4252
|
||||
active_tab_background #88c0d0
|
||||
inactive_tab_foreground #e5e9f0
|
||||
inactive_tab_background #4c566a
|
||||
tab_bar_background #3b4252
|
||||
tab_bar_margin_color none
|
||||
|
||||
# Mark colors (marked text in the terminal)
|
||||
mark1_foreground #3b4252
|
||||
mark1_background #88c0d0
|
||||
mark2_foreground #3b4252
|
||||
mark2_background #bf616a
|
||||
mark3_foreground #3b4252
|
||||
mark3_background #ebcb8b
|
||||
|
||||
# The basic 16 colors
|
||||
# black
|
||||
color0 #3b4252
|
||||
color8 #4c566a
|
||||
|
||||
# red
|
||||
color1 #bf616a
|
||||
color9 #bf616a
|
||||
|
||||
# green
|
||||
color2 #a3be8c
|
||||
color10 #a3be8c
|
||||
|
||||
# yellow
|
||||
color3 #ebcb8b
|
||||
color11 #d08770
|
||||
|
||||
# blue
|
||||
color4 #81a1c1
|
||||
color12 #5e81ac
|
||||
|
||||
# magenta
|
||||
color5 #b48ead
|
||||
color13 #b48ead
|
||||
|
||||
# cyan
|
||||
color6 #88c0d0
|
||||
color14 #8fbcbb
|
||||
|
||||
# white
|
||||
color7 #e5e9f0
|
||||
color15 #eceff4
|
||||
@@ -0,0 +1,52 @@
|
||||
# BEGIN_KITTY_FONTS
|
||||
font_family family="JetBrainsMono Nerd Font Mono"
|
||||
bold_font auto
|
||||
italic_font auto
|
||||
bold_italic_font auto
|
||||
|
||||
enable_audio_bell no
|
||||
inactive_text_alpha 0.5
|
||||
tab_bar_edge bottom
|
||||
tab_bar_style slant
|
||||
tab_powerline_style angled
|
||||
tab_bar_min_tabs 1
|
||||
active_tab_font_style bold
|
||||
inactive_tab_font_style normal
|
||||
|
||||
# Layout management
|
||||
enabled_layouts splits, stack
|
||||
map ctrl+shift+z toggle_layout stack
|
||||
map ctrl+shift+\ launch --location=vsplit --cwd=current
|
||||
map ctrl+shift+p launch --location=hsplit --cwd=current
|
||||
map ctrl+shift+h neighboring_window left
|
||||
map ctrl+shift+l neighboring_window right
|
||||
map ctrl+shift+j neighboring_window down
|
||||
map ctrl+shift+k neighboring_window up
|
||||
map ctrl+shift+up move_window up
|
||||
map ctrl+shift+left move_window left
|
||||
map ctrl+shift+right move_window right
|
||||
map ctrl+shift+down move_window down
|
||||
|
||||
map ctrl+shift+w close_window
|
||||
|
||||
map ctrl+shift+= resize_window wider 10
|
||||
map ctrl+shift+- resize_window narrower 10
|
||||
map ctrl+= slant taller 10
|
||||
map ctrl+- resize_window shorter 10
|
||||
|
||||
map ctrl+shift+1 goto_tab 1
|
||||
map ctrl+shift+2 goto_tab 2
|
||||
map ctrl+shift+3 goto_tab 3
|
||||
map ctrl+shift+4 goto_tab 4
|
||||
map ctrl+shift+5 goto_tab 5
|
||||
map ctrl+shift+6 goto_tab 6
|
||||
map ctrl+shift+7 goto_tab 7
|
||||
map ctrl+shift+8 goto_tab 8
|
||||
map ctrl+shift+9 goto_tab 9
|
||||
|
||||
|
||||
|
||||
# BEGIN_KITTY_THEME
|
||||
# Nord
|
||||
include current-theme.conf
|
||||
# END_KITTY_THEME
|
||||
@@ -0,0 +1,50 @@
|
||||
# BEGIN_KITTY_FONTS
|
||||
font_family family="JetBrainsMono Nerd Font Mono"
|
||||
bold_font auto
|
||||
italic_font auto
|
||||
bold_italic_font auto
|
||||
|
||||
enable_audio_bell no
|
||||
inactive_text_alpha 0.5
|
||||
tab_bar_edge bottom
|
||||
tab_bar_style slant
|
||||
tab_powerline_style angled
|
||||
tab_bar_min_tabs 1
|
||||
active_tab_foreground #ff2
|
||||
active_tab_background #000
|
||||
active_tab_font_style bold
|
||||
inactive_tab_foreground #444
|
||||
inactive_tab_background #999
|
||||
inactive_tab_font_style normal
|
||||
|
||||
# Layout management
|
||||
enabled_layouts splits, stack
|
||||
map ctrl+shift+z toggle_layout stack
|
||||
map ctrl+shift+\ launch --location=vsplit --cwd=current
|
||||
map ctrl+shift+p launch --location=hsplit --cwd=current
|
||||
map ctrl+shift+h neighboring_window left
|
||||
map ctrl+shift+l neighboring_window right
|
||||
map ctrl+shift+j neighboring_window down
|
||||
map ctrl+shift+k neighboring_window up
|
||||
map ctrl+shift+up move_window up
|
||||
map ctrl+shift+left move_window left
|
||||
map ctrl+shift+right move_window right
|
||||
map ctrl+shift+down move_window down
|
||||
|
||||
map ctrl+shift+w close_window
|
||||
|
||||
map ctrl+shift+= resize_window wider 10
|
||||
map ctrl+shift+- resize_window narrower 10
|
||||
map ctrl+= slant taller 10
|
||||
map ctrl+- resize_window shorter 10
|
||||
|
||||
map ctrl+shift+1 goto_tab 1
|
||||
map ctrl+shift+2 goto_tab 2
|
||||
map ctrl+shift+3 goto_tab 3
|
||||
map ctrl+shift+4 goto_tab 4
|
||||
map ctrl+shift+5 goto_tab 5
|
||||
map ctrl+shift+6 goto_tab 6
|
||||
map ctrl+shift+7 goto_tab 7
|
||||
map ctrl+shift+8 goto_tab 8
|
||||
map ctrl+shift+9 goto_tab 9
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
pragma Singleton
|
||||
import Quickshell
|
||||
|
||||
Singleton {
|
||||
readonly property string barBg: "#1a1b26"
|
||||
readonly property int barWidth: 20
|
||||
readonly property int infoBoxHeight: 20
|
||||
|
||||
readonly property int fontSize: 10
|
||||
|
||||
readonly property string infoBoxBg: "#1a1b26"
|
||||
readonly property string infoBoxActive: "#7a1b26"
|
||||
readonly property string infoBoxUrgent: "#4a1b26"
|
||||
|
||||
readonly property string infoTextActiveFg: "#ffffff"
|
||||
readonly property string infoTextFg: "#7aa2f7"
|
||||
|
||||
readonly property string separatorFg: "#aaaaaa"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
Rectangle {
|
||||
Layout.preferredWidth: BarSettings.barWidth
|
||||
Layout.preferredHeight: BarSettings.infoBoxHeight
|
||||
color: BarSettings.infoBoxBg
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import QtQuick
|
||||
|
||||
Text {
|
||||
color: BarSettings.infoTextFg
|
||||
font.bold: true
|
||||
font.pixelSize: BarSettings.fontSize
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: Quickshell.execDetached(["kitty", "-e", "nmtui"])
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
InfoBox {
|
||||
InfoText {
|
||||
color: BarSettings.separatorFg
|
||||
text: "〰"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import Quickshell.Networking
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
Variants {
|
||||
model: Quickshell.screens
|
||||
PanelWindow {
|
||||
anchors.top: true
|
||||
anchors.left: true
|
||||
anchors.bottom: true
|
||||
width: BarSettings.barWidth
|
||||
color: BarSettings.barBg
|
||||
|
||||
SystemClock {
|
||||
id: clock
|
||||
precision: SystemClock.Seconds
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 5000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
cpu_proc.running = true;
|
||||
gpu_proc.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: cpu_proc
|
||||
command: ["hmon", "cpu"]
|
||||
running: true
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: cpu_text.text = text
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: gpu_proc
|
||||
command: ["hmon", "gpu"]
|
||||
running: true
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: gpu_text.text = text
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: workspaces
|
||||
width: parent.width
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
height: 130
|
||||
spacing: 1
|
||||
|
||||
Repeater {
|
||||
model: 6
|
||||
|
||||
InfoBox {
|
||||
property var ws: Hyprland.workspaces.values.find(w => w.id === index + 1)
|
||||
property var isActive: Hyprland.focusedWorkspace?.id === (index + 1)
|
||||
property var isUrgent: ws?.urgent ?? false
|
||||
|
||||
color: isActive ? BarSettings.infoBoxActive : isUrgent ? BarSettings.infoBoxUrgent : BarSettings.infoBoxBg
|
||||
|
||||
InfoText {
|
||||
id: seconds_text
|
||||
text: index + 1
|
||||
color: parent.isActive ? BarSettings.infoTextActiveFg : BarSettings.infoTextFg
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: Hyprland.dispatch("workspace " + (index + 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Separator {}
|
||||
|
||||
InfoBox {
|
||||
InfoText {
|
||||
text: "c"
|
||||
}
|
||||
}
|
||||
|
||||
InfoBox {
|
||||
InfoText {
|
||||
id: cpu_text
|
||||
}
|
||||
}
|
||||
|
||||
InfoBox {
|
||||
InfoText {
|
||||
text: "g"
|
||||
}
|
||||
}
|
||||
|
||||
InfoBox {
|
||||
InfoText {
|
||||
id: gpu_text
|
||||
}
|
||||
}
|
||||
|
||||
Separator {}
|
||||
|
||||
InfoBox {
|
||||
InfoText {
|
||||
text: "ᛒ"
|
||||
font.pixelSize: 15
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: Quickshell.execDetached("blueberry")
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InfoBox {
|
||||
InfoText {
|
||||
text: "🕪"
|
||||
font.pixelSize: 13
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: Quickshell.execDetached("pavucontrol")
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
}
|
||||
|
||||
Separator {}
|
||||
|
||||
InfoBox {
|
||||
InfoText {
|
||||
text: Networking.connectivity == 4 ? "🌍" : "🚫"
|
||||
NetworkClick {}
|
||||
}
|
||||
}
|
||||
|
||||
InfoBox {
|
||||
InfoText {
|
||||
text: Networking.devices.values.find(n => n.type == 2).connected ? "🖧" : "🚫"
|
||||
NetworkClick {}
|
||||
}
|
||||
}
|
||||
|
||||
InfoBox {
|
||||
InfoText {
|
||||
text: Networking.devices.values.find(n => n.type == 1).connected ? "ᯤ" : "🚫"
|
||||
NetworkClick {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors {
|
||||
bottom: parent.bottom
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
bottomMargin: 8
|
||||
}
|
||||
|
||||
spacing: 5
|
||||
|
||||
Repeater {
|
||||
model: Qt.formatDateTime(clock.date, "hh:mm").split(":")
|
||||
InfoBox {
|
||||
InfoText {
|
||||
text: modelData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InfoBox {
|
||||
InfoText {
|
||||
property var ss: Qt.formatDateTime(clock.date, "ss")
|
||||
|
||||
text: ss
|
||||
font.bold: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,395 @@
|
||||
#!/usr/bin/env bash
|
||||
## Grimblast: a helper for screenshots within hyprland
|
||||
## Requirements:
|
||||
## - `grim`: screenshot utility for wayland
|
||||
## - `slurp`: to select an area
|
||||
## - `hyprctl`: to read properties of current window (provided by Hyprland)
|
||||
## - `hyprpicker`: to freeze the screen when selecting area
|
||||
## - `wl-copy`: clipboard utility (provided by wl-clipboard)
|
||||
## - `jq`: json utility to parse hyprctl output
|
||||
## - `notify-send`: to show notifications (provided by libnotify)
|
||||
## Those are needed to be installed, if unsure, run `grimblast check`
|
||||
##
|
||||
## See `man 1 grimblast` or `grimblast usage` for further details.
|
||||
|
||||
## Author: Misterio (https://github.com/misterio77)
|
||||
|
||||
## This tool is based on grimshot, with swaymsg commands replaced by their
|
||||
## hyprctl equivalents.
|
||||
## https://github.com/OctopusET/sway-contrib/blob/master/grimshot/grimshot
|
||||
|
||||
NAME="$(basename "$0")"
|
||||
|
||||
# Check whether another instance is running
|
||||
GRIMBLASTLOCK="${XDG_RUNTIME_DIR:-${XDG_CACHE_DIR:-$HOME/.cache}}/$NAME.lock"
|
||||
|
||||
killhyprpicker() {
|
||||
pidof -q hyprpicker && pkill hyprpicker
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -f "$GRIMBLASTLOCK"
|
||||
killhyprpicker
|
||||
}
|
||||
|
||||
# Entry point
|
||||
[[ -e $GRIMBLASTLOCK ]] && exit 2
|
||||
trap cleanup EXIT
|
||||
touch "$GRIMBLASTLOCK"
|
||||
|
||||
[[ $HYPRLAND_INSTANCE_SIGNATURE ]] || {
|
||||
echo "Error: HYPRLAND_INSTANCE_SIGNATURE not set! (is hyprland running?)" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Globals
|
||||
# General settings. These can be set by the user. See man page for more details
|
||||
[[ $DEFAULT_TARGET_DIR ]] || {
|
||||
USER_DIRS="${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs"
|
||||
[[ -f $USER_DIRS ]] && source "$USER_DIRS"
|
||||
DEFAULT_TARGET_DIR="${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}}"
|
||||
}
|
||||
: "${DEFAULT_TMP_EDITOR_DIR:=/tmp}" "${GRIMBLAST_EDITOR:=gimp}" "${DATE_FORMAT:=%Y%m%d_%H%M%S}"
|
||||
|
||||
# Screenshot variables. In addition to these, there's:
|
||||
# SCALE
|
||||
EXPIRE_TIME=3000
|
||||
FILETYPE=png
|
||||
|
||||
# These have an effect depending on whether they're set
|
||||
# CURSOR
|
||||
# FREEZE
|
||||
NOTIFY=false
|
||||
SHOW_FILE_NOTIFY=false
|
||||
WAIT=0
|
||||
|
||||
# Notification functions
|
||||
notify() {
|
||||
notify-send -t "$EXPIRE_TIME" -a "$NAME" "$@"
|
||||
}
|
||||
|
||||
notify::ok() {
|
||||
if $NOTIFY; then
|
||||
notify "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
notify::error() {
|
||||
if $NOTIFY; then
|
||||
TITLE=${2:-"Screenshot"}
|
||||
MESSAGE=${1:-"Error taking screenshot with grim"}
|
||||
notify -u critical "$TITLE" "$MESSAGE"
|
||||
fi
|
||||
echo "$1" >&2
|
||||
}
|
||||
|
||||
# If invoked with -h, print usage before dying
|
||||
die() {
|
||||
killhyprpicker
|
||||
local msg OPTIND option
|
||||
while getopts 'h' option; do
|
||||
case "$option" in
|
||||
h) usage >&2 ;;
|
||||
?) echo "die: Usage: die [-h] MESSAGE" >&2 ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
msg=${1:-Bye}
|
||||
notify::error "Error: $msg"
|
||||
exit 2
|
||||
}
|
||||
|
||||
notify::showparentdir() {
|
||||
if $SHOW_FILE_NOTIFY; then
|
||||
if [[ $(notify::ok -A 'Show file="Show file"' "$@") == "Show file" ]]; then
|
||||
gdbus call --session --dest org.freedesktop.FileManager1 --object-path /org/freedesktop/FileManager1 --method org.freedesktop.FileManager1.ShowItems "['file://$4']" "" || die "Could not display parent directory with gdbus"
|
||||
fi
|
||||
else
|
||||
notify::ok "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Miscellaneous functions
|
||||
grimblast::wait() {
|
||||
[[ $WAIT == 0 ]] || sleep "$WAIT"
|
||||
}
|
||||
|
||||
get-mime-type() {
|
||||
case $FILETYPE in
|
||||
png | jpeg) echo "image/$FILETYPE" ;;
|
||||
ppm) echo "image/x-portable-pixmap" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
freezescreen() {
|
||||
hyprpicker -rz &
|
||||
sleep 0.2
|
||||
}
|
||||
|
||||
# Checks whether an individual tool is available
|
||||
# If invoked with -q (quiet), no output is printed, useful for use in tests
|
||||
# Exits with 0 if the tool is available, non-zero otherwise
|
||||
grimblast::check() {
|
||||
local cmd result OPTIND option status quiet=false
|
||||
while getopts 'q' option; do
|
||||
case "$option" in
|
||||
q) quiet=true ;;
|
||||
?) echo 'check: Usage: check [-q] COMMAND' >&2 ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
cmd=$1
|
||||
command -v "$cmd" >/dev/null 2>&1
|
||||
status=$?
|
||||
if ((status == 0)); then
|
||||
result="OK"
|
||||
else
|
||||
result="NOT FOUND"
|
||||
fi
|
||||
$quiet || echo " $cmd: $result"
|
||||
return $status
|
||||
}
|
||||
|
||||
# The actual grim command used is printed to stderr
|
||||
screenshot() {
|
||||
local file="$1" geom="$2" output="$3"
|
||||
xargs --verbose grim <<<"${CURSOR:+-c} ${SCALE:+-s \"$SCALE\"} -t \"$FILETYPE\" ${output:+-o \"$output\"} ${geom:+-g \"$geom\"} \"$file\""
|
||||
}
|
||||
|
||||
# Special actions: usage and check. These are special because they allow to exit early
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage:
|
||||
$NAME [-n|--notify] [-o|--openparentdir] [-e|--expire-time <ms>] [-c|--cursor] [-f|--freeze] [-w N|--wait N] [-s N|--scale N] [-t TYPE|--filetype TYPE] (copy|save|copysave|edit) [active|screen|output|area] [FILE|-]
|
||||
$NAME check
|
||||
$NAME usage
|
||||
|
||||
Commands:
|
||||
copy: Copy the screenshot data into the clipboard.
|
||||
save: Save the screenshot to a regular file or '-' to pipe to STDOUT.
|
||||
copysave: Combine the previous 2 options.
|
||||
edit: Open screenshot in the image editor of your choice (default is gimp). See man page for info.
|
||||
check: Verify if required tools are installed and exit.
|
||||
usage: Show this message and exit.
|
||||
|
||||
Targets:
|
||||
active: Currently active window.
|
||||
screen: All visible outputs.
|
||||
output: Currently active output.
|
||||
area: Manually select a region or window.
|
||||
EOF
|
||||
}
|
||||
|
||||
check() {
|
||||
local status
|
||||
echo "Checking if required tools are installed. If something is missing, install it to your system and make it available in PATH..."
|
||||
for t in grim slurp hyprctl hyprpicker wl-copy jq notify-send; do
|
||||
grimblast::check "$t" || status=$?
|
||||
done
|
||||
exit $status
|
||||
}
|
||||
|
||||
# Target functions. These calculate global variables depending on the target.
|
||||
# Specifically: GEOM, WHAT and OUTPUT. Not all would be set by all targets.
|
||||
# These would later be used by the action functions.
|
||||
active() {
|
||||
local focused app_id
|
||||
grimblast::wait
|
||||
focused="$(hyprctl activewindow -j)" app_id=$(jq -r '.class' <<<"$focused")
|
||||
GEOM="$(jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' <<<"$focused")"
|
||||
WHAT="$app_id window"
|
||||
}
|
||||
|
||||
screen() {
|
||||
grimblast::wait
|
||||
GEOM=""
|
||||
WHAT="Screen"
|
||||
}
|
||||
|
||||
output() {
|
||||
grimblast::wait
|
||||
GEOM=""
|
||||
OUTPUT=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .name')
|
||||
WHAT="$OUTPUT"
|
||||
}
|
||||
|
||||
area() {
|
||||
local fullscreen_workspaces workspaces windows
|
||||
[[ $CURSOR ]] && die "'-c|--cursor' cannot be used with TARGET 'area'"
|
||||
|
||||
if [[ $FREEZE ]] && grimblast::check -q hyprpicker; then
|
||||
freezescreen
|
||||
fi
|
||||
|
||||
# disable animation for layer namespace "selection" (slurp)
|
||||
# this removes the black border seen around screenshots
|
||||
hyprctl keyword layerrule "match:selection, no_anim on" >/dev/null
|
||||
|
||||
fullscreen_workspaces="$(hyprctl workspaces -j | jq -r 'map(select(.hasfullscreen) | .id)')"
|
||||
workspaces="$(hyprctl monitors -j | jq -r '[(foreach .[] as $monitor (0; if $monitor.specialWorkspace.name == "" then $monitor.activeWorkspace else $monitor.specialWorkspace end)).id]')"
|
||||
windows="$(hyprctl clients -j | jq -r --argjson workspaces "$workspaces" --argjson fullscreenWorkspaces "$fullscreen_workspaces" 'map((select(([.workspace.id] | inside($workspaces)) and ([.workspace.id] | inside($fullscreenWorkspaces) | not) or .fullscreen > 0)))')"
|
||||
# convert SLURP_ARGS to a bash array
|
||||
IFS=' ' read -ra SLURP_ARGS <<<"$SLURP_ARGS"
|
||||
GEOM="$(jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' <<<"$windows" | slurp "${SLURP_ARGS[@]}")"
|
||||
|
||||
grimblast::wait
|
||||
|
||||
# Check if user exited slurp without selecting the area
|
||||
[[ $GEOM ]] || {
|
||||
killhyprpicker
|
||||
exit 1
|
||||
}
|
||||
WHAT="Area"
|
||||
}
|
||||
|
||||
# Action functions.
|
||||
# These take the global variables set by target functions and take the screenshot.
|
||||
copy() {
|
||||
[[ $FILETYPE == "png" ]] || die "Clipboard operations only support PNG format. Use --filetype png or omit the option."
|
||||
screenshot - "$GEOM" "$OUTPUT" | wl-copy --type "$(get-mime-type)" || die "Clipboard error"
|
||||
notify::ok "$WHAT copied to buffer"
|
||||
}
|
||||
|
||||
save() {
|
||||
local file title message
|
||||
file="${1:-$DEFAULT_TARGET_DIR/$(date +"$DATE_FORMAT").$FILETYPE}"
|
||||
screenshot "$file" "$GEOM" "$OUTPUT" || die "Could not take screenshot with grim"
|
||||
title="Screenshot of $WHAT" message="$(basename "$file")"
|
||||
killhyprpicker
|
||||
notify::showparentdir "$title" "$message" -i "$file"
|
||||
echo "$file"
|
||||
}
|
||||
|
||||
edit() {
|
||||
local editor="${GRIMBLAST_EDITOR%% *}"
|
||||
grimblast::check -q "$editor" || die "$editor is not installed"
|
||||
local file title message
|
||||
file="${1:-$DEFAULT_TMP_EDITOR_DIR/$(date +"$DATE_FORMAT").$FILETYPE}"
|
||||
screenshot "$file" "$GEOM" "$OUTPUT" || die "Could not take screenshot"
|
||||
title="Screenshot of $WHAT" message="Open screenshot in $editor"
|
||||
notify::ok "$title" "$message" -i "$file"
|
||||
$GRIMBLAST_EDITOR "$file"
|
||||
echo "$file"
|
||||
}
|
||||
|
||||
copysave() {
|
||||
[[ $FILETYPE == "png" ]] || die "Clipboard operations only support PNG format. Use --filetype png or omit the option."
|
||||
local file title message
|
||||
file="${1:-$DEFAULT_TARGET_DIR/$(date +"$DATE_FORMAT").$FILETYPE}"
|
||||
if [[ $file = "-" ]]; then
|
||||
screenshot - "$GEOM" "$OUTPUT" | tee >(wl-copy --type "$(get-mime-type)") || die "Clipboard error"
|
||||
notify::ok "$WHAT copied to buffer and piped to stdout"
|
||||
else
|
||||
screenshot - "$GEOM" "$OUTPUT" | tee "$file" | wl-copy --type "$(get-mime-type)" || die "Clipboard error"
|
||||
title="Screenshot of $WHAT"
|
||||
message="$WHAT copied to buffer and saved to $file"
|
||||
notify::showparentdir "$title" "$message" -i "$file"
|
||||
echo "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
parse-action() {
|
||||
local action="$1" file="$2"
|
||||
case "$action" in
|
||||
copy) copy ;;
|
||||
save) save "$file" ;;
|
||||
edit) edit "$file" ;;
|
||||
copysave) copysave "$file" ;;
|
||||
*) die -h "Unknown action $action" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
parse-target() {
|
||||
case "$1" in
|
||||
active) active ;;
|
||||
screen) screen ;;
|
||||
output) output ;;
|
||||
area) area ;;
|
||||
window) die "$(echo -e "Target 'window' is now included in 'area'.\nSimply run with 'area' and single click over the window you want.")" ;;
|
||||
*) die -h "Unknown target to take a screen shot from $1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
local parsed_args
|
||||
|
||||
parsed_args="$(getopt --name "$NAME" --options 'nocfe:w:s:t:' --longoptions 'notify,openparentdir,cursor,freeze,expire-time:,wait:,scale:,filetype:' -- "$@")" || {
|
||||
usage >&2
|
||||
exit 1
|
||||
}
|
||||
eval "set -- $parsed_args"
|
||||
|
||||
while true; do
|
||||
case $1 in
|
||||
-n | --notify)
|
||||
NOTIFY=true
|
||||
shift
|
||||
;;
|
||||
-o | --openparentdir)
|
||||
SHOW_FILE_NOTIFY=true
|
||||
shift
|
||||
;;
|
||||
-e | --expire-time)
|
||||
[[ $2 =~ ^[0-9]+$ ]] || {
|
||||
echo "$NAME: ERROR: Invalid or missing argument for '-e|--expire-time'" >&2
|
||||
exit 1
|
||||
}
|
||||
EXPIRE_TIME=$2
|
||||
shift 2
|
||||
;;
|
||||
-c | --cursor)
|
||||
CURSOR=1
|
||||
shift
|
||||
;;
|
||||
-f | --freeze)
|
||||
FREEZE=1
|
||||
shift
|
||||
;;
|
||||
-w | --wait)
|
||||
[[ $2 =~ ^[0-9]*(\.[0-9]+)?$ ]] || {
|
||||
echo "$NAME: ERROR: Invalid value for '-w|--wait'" >&2
|
||||
exit 1
|
||||
}
|
||||
WAIT=$2
|
||||
shift 2
|
||||
;;
|
||||
-s | --scale)
|
||||
[[ "$2" =~ ^[0-9]*(\.[0-9]+)?$ ]] || {
|
||||
echo "$NAME: ERROR: Invalid or missing argument for '-s|--scale'" >&2
|
||||
exit 1
|
||||
}
|
||||
SCALE=$2
|
||||
shift 2
|
||||
;;
|
||||
-t | --filetype)
|
||||
[[ "$2" =~ ^(png|ppm|jpeg)$ ]] || {
|
||||
echo "$NAME: ERROR: Invalid filetype '$2'. Must be png, ppm, or jpeg" >&2
|
||||
exit 1
|
||||
}
|
||||
FILETYPE=$2
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "$NAME: ERROR: Invalid option: $1" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
ACTION="${1:-usage}"
|
||||
if [[ $1 =~ ^(usage|check)$ ]]; then
|
||||
"$1"
|
||||
exit
|
||||
fi
|
||||
shift
|
||||
parse-target "${1:-screen}"
|
||||
shift
|
||||
parse-action "$ACTION" "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user