From afe469016c54573e70f628444c9da4e395b2b830 Mon Sep 17 00:00:00 2001 From: danix Date: Wed, 13 Nov 2024 15:37:12 +0100 Subject: [PATCH] major cleanup of old scripts + added pywal for sublime text and autolocking with betterlockscreen and xscreensaver --- Xresources | 11 --- home-bin/blackpearl-appsmenu.sh | 1 + home-bin/blackpearl-powermenu.sh | 9 +-- home-bin/blackpearl-runner.sh | 1 + home-bin/blackpearl-scrotmenu.sh | 4 +- home-bin/blackpearl-utilsmenu.sh | 1 + home-bin/blackpearl-window.sh | 3 + home-bin/i3-exit | 12 +--- home-bin/notify_screensaver.sh | 12 ++++ home-bin/pywal_sublime.py | 76 +++++++++++++++++++++ home-bin/scrot.sh | 41 +++++++++++ home-bin/wal.sh | 10 ++- home-config/betterlockscreen/custom-pre.sh | 16 +++++ home-config/wal/templates/colors.Xresources | 70 +++++++++++++++++++ xprofile | 27 +++----- 15 files changed, 247 insertions(+), 47 deletions(-) delete mode 100644 Xresources mode change 100644 => 100755 home-bin/blackpearl-appsmenu.sh mode change 100644 => 100755 home-bin/blackpearl-powermenu.sh mode change 100644 => 100755 home-bin/blackpearl-runner.sh mode change 100644 => 100755 home-bin/blackpearl-scrotmenu.sh mode change 100644 => 100755 home-bin/blackpearl-utilsmenu.sh mode change 100644 => 100755 home-bin/blackpearl-window.sh mode change 100644 => 100755 home-bin/i3-exit create mode 100755 home-bin/notify_screensaver.sh create mode 100755 home-bin/pywal_sublime.py create mode 100755 home-bin/scrot.sh create mode 100755 home-config/betterlockscreen/custom-pre.sh create mode 100644 home-config/wal/templates/colors.Xresources diff --git a/Xresources b/Xresources deleted file mode 100644 index 2337db3..0000000 --- a/Xresources +++ /dev/null @@ -1,11 +0,0 @@ -Xcursor.theme: Oxygen_Zion - -!URxvt*inheritPixmap: true -!URxvt*transparent: true -! URxvt*shading: 0 to 99 darkens, 101 to 200 lightens -URxvt*shading: 70 - -URxvt.depth: 32 -URxvt.background: [75]#000000 -URxvt.scrollbar: false - diff --git a/home-bin/blackpearl-appsmenu.sh b/home-bin/blackpearl-appsmenu.sh old mode 100644 new mode 100755 index 6c499c4..62ee1dd --- a/home-bin/blackpearl-appsmenu.sh +++ b/home-bin/blackpearl-appsmenu.sh @@ -1,4 +1,5 @@ #!/bin/sh +# fullscreen menu for all applications # rofi -no-lazy-grab -show drun -theme blackpearl/appmenu rofi -no-lazy-grab -show drun -theme darknix/appmenu.rasi diff --git a/home-bin/blackpearl-powermenu.sh b/home-bin/blackpearl-powermenu.sh old mode 100644 new mode 100755 index fad6b19..c5832ad --- a/home-bin/blackpearl-powermenu.sh +++ b/home-bin/blackpearl-powermenu.sh @@ -1,14 +1,13 @@ #!/bin/bash -# rofi_command="rofi -theme blackpearl/powermenu.rasi" rofi_command="rofi -theme darknix/powermenu.rasi" ### Options ### power_off="" reboot="" lock="" -#suspend="⏾" log_out="󰿅" + # Variable passed to rofi options="$power_off\n$reboot\n$lock\n$log_out" @@ -26,12 +25,8 @@ case $chosen in ;; $lock) sleep 1 - i3lock-fancy + betterlockscreen -l blur --off 60 ;; -# $suspend) -# sleep 1 -# i3suspend -# ;; $log_out) i3-exit ;; diff --git a/home-bin/blackpearl-runner.sh b/home-bin/blackpearl-runner.sh old mode 100644 new mode 100755 index 36517d1..86b6c1b --- a/home-bin/blackpearl-runner.sh +++ b/home-bin/blackpearl-runner.sh @@ -1,4 +1,5 @@ #!/bin/sh +# Alt+F2 shortcut runner rofi -no-lazy-grab -show run -theme darknix/runner.rasi diff --git a/home-bin/blackpearl-scrotmenu.sh b/home-bin/blackpearl-scrotmenu.sh old mode 100644 new mode 100755 index dbafcb7..9c8d2fa --- a/home-bin/blackpearl-scrotmenu.sh +++ b/home-bin/blackpearl-scrotmenu.sh @@ -11,9 +11,9 @@ options="$screen\n$area" chosen="$(echo -e "$options" | $rofi_command -dmenu -selected-row 1)" case $chosen in $screen) - i3-scrot -d 3 + scrot.sh -d 3 ;; $area) - i3-scrot -s + scrot.sh -s ;; esac diff --git a/home-bin/blackpearl-utilsmenu.sh b/home-bin/blackpearl-utilsmenu.sh old mode 100644 new mode 100755 index 8c2beaa..e3fdb88 --- a/home-bin/blackpearl-utilsmenu.sh +++ b/home-bin/blackpearl-utilsmenu.sh @@ -1,4 +1,5 @@ #!/bin/bash +# NOT USED ATM rofi_command="rofi -theme darknix/utilsmenu.rasi" diff --git a/home-bin/blackpearl-window.sh b/home-bin/blackpearl-window.sh old mode 100644 new mode 100755 index 68d4d4f..71f5968 --- a/home-bin/blackpearl-window.sh +++ b/home-bin/blackpearl-window.sh @@ -1,4 +1,7 @@ #!/bin/sh +# window switcher +# - Alt+Tab --> desktop +# - Win+Tab --> all windows case $1 in all ) diff --git a/home-bin/i3-exit b/home-bin/i3-exit old mode 100644 new mode 100755 index 13858ff..efa7dc8 --- a/home-bin/i3-exit +++ b/home-bin/i3-exit @@ -1,24 +1,18 @@ #!/bin/bash rofi_command="rofi -theme darknix/i3exit.rasi" -NO="ﰸ" +NO="" YES="" options="$YES\n$NO" chosen="$(echo -e "$options" | $rofi_command -dmenu -selected-row 1)" case $chosen in "$YES") - # take wallpaper.sh down with you - for pid in $(cat /tmp/wallpaper.pid); do - # sending all term signals. hopefully one of them will work! - kill -15 $pid - kill -1 $pid - kill -9 $pid - done - rm /tmp/wallpaper.pid + # exit i3 i3-msg exit ;; "$NO") + # do nothing exit 0 ;; esac diff --git a/home-bin/notify_screensaver.sh b/home-bin/notify_screensaver.sh new file mode 100755 index 0000000..f96bd10 --- /dev/null +++ b/home-bin/notify_screensaver.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +for p in $(seq 0 2 100); do + dunstify --icon preferences-desktop-screensaver \ + -h int:value:$p \ + -h string:x-dunst-stack-tag:progress-lock \ + --urgency=critical \ + --timeout=500 "lock screen in 10s " "move or use corners" + sleep 0.1 +done diff --git a/home-bin/pywal_sublime.py b/home-bin/pywal_sublime.py new file mode 100755 index 0000000..44f01ad --- /dev/null +++ b/home-bin/pywal_sublime.py @@ -0,0 +1,76 @@ +#! /usr/bin/env python +import json +import os + + +def make_element(name, scope, **kwargs): + """Helper function for generating color scheme entries""" + result = {} + result['name'] = name + result['scope'] = scope + result.update(kwargs) + return result + + +if __name__ == '__main__': + wal_path = os.path.join(os.environ["HOME"], '.cache/wal/colors.json') + with open(wal_path) as file: + wal_scheme = json.load(file) + wal_colors = [wal_scheme['colors']['color%d' % i] for i in range(16)] + + result_scheme = {} + result_scheme['name'] = 'Pywal' + + # global settings + global_settings = {} + global_settings['background'] = wal_scheme['special']['background'] + global_settings['foreground'] = wal_scheme['special']['foreground'] + global_settings['caret'] = wal_scheme['special']['foreground'] + global_settings['invisibles'] = wal_colors[1] + global_settings['lineHighlight'] = wal_colors[2] + global_settings['selection'] = wal_colors[6] + + # Color scheme elements + settings = [] + settings.append(make_element('Comment', 'comment', foreground=wal_colors[2])) + settings.append(make_element('String', 'string', foreground=wal_colors[4])) + settings.append(make_element('Number', 'constant.numeric', foreground=wal_colors[5])) + settings.append(make_element('Built-in constant', 'constant.language', foreground=wal_colors[5])) + settings.append(make_element('User-defined constant', 'constant.character, constant.other', + foreground=wal_colors[5])) + settings.append(make_element('Variable', 'variable', fontStyle='')) + settings.append(make_element('Storage', 'storage', foreground=wal_colors[3], fontStyle='')) + settings.append(make_element('Storage type', 'storage.type', foreground=wal_colors[6], fontStyle='italic')) + settings.append(make_element('Class name', 'entity.name.class', foreground=wal_colors[1], + fontStyle='italic')) + settings.append(make_element('Inherited class', 'entity.other.inherited-class', foreground=wal_colors[1], + fontStyle='italic')) + settings.append(make_element('Function name', 'entity.name.function', foreground=wal_colors[1], fontStyle='italic')) + settings.append(make_element('Function argument', 'variable.parameter', foreground=wal_colors[6], fontStyle='')) + settings.append(make_element('Tag name', 'entity.name.tag', foreground=wal_colors[3], fontStyle='')) + settings.append(make_element('Tag attribute', 'entity.other.attribute-name', foreground=wal_colors[1], + fontStyle='')) + settings.append(make_element('Library function', 'support.function', foreground=wal_colors[6], fontStyle='')) + settings.append(make_element('Library constant', 'support.constant', foreground=wal_colors[6], fontStyle='')) + settings.append(make_element('Library class/type', 'support.class, support.type', foreground=wal_colors[6], + fontStyle='italic')) + settings.append(make_element('Library variable', 'support.other.variable', fontStyle='')) + settings.append(make_element('Invalid', 'invalid', fontStyle='', + foreground=wal_scheme['special']['foreground'], background=wal_colors[5])) + settings.append(make_element('Invalid deprecaded', 'invalid.deprecated', fontStyle='', + foreground=wal_scheme['special']['foreground'], background=wal_colors[4])) + + result_scheme['globals'] = global_settings + result_scheme['rules'] = settings + result_scheme['semanticClass'] = 'theme.dark.pywal' + + theme_path = os.path.join(os.environ['HOME'], '.config/sublime-text/Packages/User/PyWal.sublime-color-scheme') + with open(theme_path, 'w') as file: + json.dump(result_scheme, file, indent=4) + + + + + + + diff --git a/home-bin/scrot.sh b/home-bin/scrot.sh new file mode 100755 index 0000000..ef582ee --- /dev/null +++ b/home-bin/scrot.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# take a screenshot of the whole desktop or just a rectangular area +# uses scrot to take the screenshot +# uses dunstify to output a countdown in desktop mode + +OUTPUT_FOLDER="/home/danix/Pictures/screenshots" +OUTPUT_FILE="screenshot_$(date +%Y%m%d-%H%M%S).png" + +# Analizza le opzioni +while getopts "d:s" opt; do + case $opt in + d) + # capture the whole screen after n secs (3 if not specified) + count="$OPTARG" + if [[ ! $count =~ ^[0-9]+$ ]]; then + count=3 + fi + while [ $count -ge 1 ]; do + dunstify -i info -t 1000 -h string:x-dunst-stack-tag:scrotDesk "Taking screenshot in ${count}" + sleep 1 + ((count--)) + done + scrot -d 1 -F ${OUTPUT_FOLDER}/${OUTPUT_FILE} + sleep 1 + xdg-open ${OUTPUT_FOLDER}/${OUTPUT_FILE} + exit 0 + ;; + s) + # capture selection + scrot -l mode=edge width=2 -s -F ${OUTPUT_FOLDER}/${OUTPUT_FILE} + sleep 1 + xdg-open ${OUTPUT_FOLDER}/${OUTPUT_FILE} + exit 0 + ;; + \?) + echo "Invalid Option: -$OPTARG" >&2 + exit 1 + ;; + esac +done diff --git a/home-bin/wal.sh b/home-bin/wal.sh index 079c88c..39b1712 100644 --- a/home-bin/wal.sh +++ b/home-bin/wal.sh @@ -16,12 +16,20 @@ stalonetray & # update firefox theme pywalfox update -# link background image to be used by firefox +# update sublime_text theme +pywal_sublime.py + +# link background image to be used by whatever app needs it. IMG=$(cat ~/.cache/wal/wal) FNAME=$(basename -- $IMG) EXT="${FNAME##*.}" ln -sf $IMG ~/.cache/wal/wpaper.${EXT} +# update betterlockscreen images +betterlockscreen -u $IMG +ln -sf ~/.cache/betterlockscreen/1-VGA-1/blur.png ~/Pictures/wallpapers/.current/blur.png + +# restart hideIt for the bars kill $(cat /tmp/hideIt-*.pid) || true sleep 1 hideIt.sh --name "^polybar-top_VGA-1$" --hover --peek 3 --direction top --steps 25 & disown diff --git a/home-config/betterlockscreen/custom-pre.sh b/home-config/betterlockscreen/custom-pre.sh new file mode 100755 index 0000000..df1686d --- /dev/null +++ b/home-config/betterlockscreen/custom-pre.sh @@ -0,0 +1,16 @@ +#! /bin/bash +#set -ex +LOG="/tmp/xsc.log" +[ -f $LOG ] && rm $LOG + +xscreensaver-command -activate +xscreensaver-command -watch > /tmp/xsc.log & +pid=$(pidof xscreensaver-command) +while true; do + blank=$(tail -n 1 /tmp/xsc.log | cut -d ' ' -f1) + if [[ $blank == "UNBLANK" ]]; then + kill $pid + rm $LOG + break + fi +done diff --git a/home-config/wal/templates/colors.Xresources b/home-config/wal/templates/colors.Xresources new file mode 100644 index 0000000..e7c8b6d --- /dev/null +++ b/home-config/wal/templates/colors.Xresources @@ -0,0 +1,70 @@ +Xcursor.theme: Oxygen_Zion + +! X colors. +! Generated by 'wal' +*foreground: {foreground} +*background: {background} +*.foreground: {foreground} +*.background: {background} +emacs*foreground: {foreground} +emacs*background: {background} +URxvt*foreground: {foreground} +XTerm*foreground: {foreground} +UXTerm*foreground: {foreground} +URxvt*background: {background.alpha} +XTerm*background: {background} +UXTerm*background: {background} +URxvt*cursorColor: {cursor} +XTerm*cursorColor: {cursor} +UXTerm*cursorColor: {cursor} +URxvt*borderColor: {background.alpha} + +! Colors 0-15. +*.color0: {color0} +*color0: {color0} +*.color1: {color1} +*color1: {color1} +*.color2: {color2} +*color2: {color2} +*.color3: {color3} +*color3: {color3} +*.color4: {color4} +*color4: {color4} +*.color5: {color5} +*color5: {color5} +*.color6: {color6} +*color6: {color6} +*.color7: {color7} +*color7: {color7} +*.color8: {color8} +*color8: {color8} +*.color9: {color9} +*color9: {color9} +*.color10: {color10} +*color10: {color10} +*.color11: {color11} +*color11: {color11} +*.color12: {color12} +*color12: {color12} +*.color13: {color13} +*color13: {color13} +*.color14: {color14} +*color14: {color14} +*.color15: {color15} +*color15: {color15} + +! Black color that will not be affected by bold highlighting. +*.color66: {color0} +*color66: {color0} + +! Xclock colors. +XClock*foreground: {foreground} +XClock*background: {background} +XClock*majorColor: rgba:{color15.xrgba} +XClock*minorColor: rgba:{color15.xrgba} +XClock*hourColor: rgba:{color15.xrgba} +XClock*minuteColor: rgba:{color15.xrgba} +XClock*secondColor: rgba:{color15.xrgba} + +! Set depth to make transparency work. +URxvt*depth: 32 diff --git a/xprofile b/xprofile index 79ef7ab..5704c40 100644 --- a/xprofile +++ b/xprofile @@ -7,24 +7,17 @@ numlockx & picom -b xdg-user-dirs-update & dunst & -playerctld daemon & -#dex -a -s ~/.config/autostart/ & -#conky & xscreensaver --no-splash & /home/danix/bin/lightsOn.sh & - -# USELESS!!! -#wicd-client --tray & -# wallpaper.sh ~/Pictures/wallpapers/wallhaven/ & -#xbacklight -set 100 & -#~/.fehbg & -#syndaemon -K -t -R -i 2 -d & -#feh-blur -b 5 --no-animate -d & -# ~/bin/wallpaper.sh ~/Pictures/wallpapers/Chrome_OS_Wallpapers_Late_2020/Element_by_Rutger_Paulusse/ & -# /home/danix/Pictures/wallpapers/Walls-by-JFL/ -#lxqt-powermanagement & -#xautolock -time 10 -locker i3lock-wrapper -notify 30 -notifier "notify-send 'locking the system' '30 seconds before locking system.' --icon=dialog-warning" & -#compton --dbus --config ~/.config/compton.conf & -#conky -c ~/.config/conky/qlocktwo.conkyrc & +xautolock \ + -time 5 \ + -corners 0+-- \ + -cornersize 10 \ + -cornerdelay 1 \ + -cornerredelay 5 \ + -notify 11 \ + -locker "betterlockscreen -l blur" \ + -secure \ + -notifier notify_screensaver.sh & -- 2.20.1