From 5a57229dc9e3a62f0ed25375a55cbb60168cf2ce Mon Sep 17 00:00:00 2001 From: Aleksander Cynarski Date: Sun, 18 Jul 2021 13:34:20 +0200 Subject: [PATCH] kanshi, python swayidle, zsh title --- .config/kanshi/config | 11 +++ .config/sway/bin/lock.sh | 3 +- .config/sway/bin/swayidle-conf | 68 +++++++++++++++++++ .config/sway/idle.yml | 11 +++ .config/sway/sway.d/01-general.conf | 6 +- .config/sway/sway.d/02-layout.conf | 2 +- .config/sway/sway.d/05-output.conf | 30 ++++---- .config/sway/sway.d/07-hotkeys.conf | 15 +++- .config/sway/sway.d/10-autostart.conf | 2 + .config/systemd/user/kanshi.service | 14 ++++ .../sway-session.target.wants/kanshi.service | 1 + .../swayidle.service | 1 - .config/systemd/user/swayidle.service | 9 ++- .../kanshi.service | 1 + .config/waybar/config | 11 +++ .config/waybar/style.css | 7 +- .zshrc | 16 ++++- 17 files changed, 178 insertions(+), 30 deletions(-) create mode 100644 .config/kanshi/config create mode 100755 .config/sway/bin/swayidle-conf create mode 100644 .config/sway/idle.yml create mode 100644 .config/systemd/user/kanshi.service create mode 120000 .config/systemd/user/sway-session.target.wants/kanshi.service delete mode 120000 .config/systemd/user/sway-session.target.wants/swayidle.service create mode 120000 .config/systemd/user/wayland-session.target.wants/kanshi.service diff --git a/.config/kanshi/config b/.config/kanshi/config new file mode 100644 index 0000000..afb2c6c --- /dev/null +++ b/.config/kanshi/config @@ -0,0 +1,11 @@ +profile Home { + output eDP-1 mode 1920x1080@60Hz position 1920,0 + output DP-3 mode 1920x1080@60Hz position 3830,0 + output DP-4 mode 1920x1080@60Hz position 0,0 +} + +profile HomeAS { + output eDP-1 mode 1920x1080@60Hz position 1920,0 + output DP-5 mode 1920x1080@60Hz position 3830,0 + output DP-6 mode 1920x1080@60Hz position 0,0 +} diff --git a/.config/sway/bin/lock.sh b/.config/sway/bin/lock.sh index 7098b48..d2d2912 100755 --- a/.config/sway/bin/lock.sh +++ b/.config/sway/bin/lock.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash -swaylock --daemonize \ - --indicator-radius 100 \ +swaylock --indicator-radius 100 \ --indicator-thickness 12 \ --ring-color 2E3440 \ --key-hl-color ECEFF4 \ diff --git a/.config/sway/bin/swayidle-conf b/.config/sway/bin/swayidle-conf new file mode 100755 index 0000000..fda12d3 --- /dev/null +++ b/.config/sway/bin/swayidle-conf @@ -0,0 +1,68 @@ +#!/usr/bin/python3 + +import yaml +import sys +import os + +config_files = [ + '/etc/sway/idle.yml', + os.path.expanduser('~/.config/sway/idle.yml'), +] + +env_config = os.environ.get('SWAYIDLE_CONFIG') +if env_config is not None: + config_files += env_config + +options = { + 'debug': '-d', + 'wait': '-w', +} + +config = {} + +found = False +for f in config_files: + if not os.path.isfile(f): + continue + found = True + try: + with open(f) as conf: + newconf = yaml.load(conf, yaml.SafeLoader) + config.update(newconf) + except Exception as e: + sys.stderr('{}: Could not load {} ({})'.format(sys.argv[0], f, e)) + sys.stderr.flush() + +if not found: + sys.stderr('{}: WARNING: No config file found'.format(sys.argv[0])) + sys.stderr.flush() + +args = ['swayidle'] + +for k in config: + c = config[k] + if c is None or c is False or c is []: + continue + + if k == 'timeouts': + for t in c: + args.append('timeout') + args.append(str(t['timeout'])) + args.append(t['command']) + if 'resume' in t: + args.append('resume') + args.append(t['resume']) + + continue + + if k in options and c: + args.append(options[k]) + continue + + args.append(k) + args.append(c) + +args.extend(sys.argv[1:]) + +os.execvp('swayidle', args) + diff --git a/.config/sway/idle.yml b/.config/sway/idle.yml new file mode 100644 index 0000000..f09fdbd --- /dev/null +++ b/.config/sway/idle.yml @@ -0,0 +1,11 @@ +--- +debug: false +wait: true +timeouts: + - timeout: 300 + command: 'swaylock -f -c 000000' + - timeout: 600 + command: 'swaymsg "output * dpms off"' + resume: 'swaymsg "output * dpms on"' +before-sleep: 'swaylock -f -c 000000' + diff --git a/.config/sway/sway.d/01-general.conf b/.config/sway/sway.d/01-general.conf index 8f2aebb..b7aac48 100644 --- a/.config/sway/sway.d/01-general.conf +++ b/.config/sway/sway.d/01-general.conf @@ -1,2 +1,6 @@ #general -set $BIN_DIR ~/.config/sway/bin \ No newline at end of file +set $BIN_DIR ~/.config/sway/bin +set $laptop eDP-1 + +bindswitch --reload --locked lid:on output $laptop disable +bindswitch --reload --locked lid:off output $laptop enable \ No newline at end of file diff --git a/.config/sway/sway.d/02-layout.conf b/.config/sway/sway.d/02-layout.conf index f742d35..6d896fb 100644 --- a/.config/sway/sway.d/02-layout.conf +++ b/.config/sway/sway.d/02-layout.conf @@ -27,4 +27,4 @@ client.unfocused $color2 $background $color1 $color2 $color2 client.urgent $foreground $background $color7 $foreground $foreground -output * bg ~/Wallpapers/deusex.jpg fill \ No newline at end of file +# output * bg ~/Wallpapers/deusex.jpg fill \ No newline at end of file diff --git a/.config/sway/sway.d/05-output.conf b/.config/sway/sway.d/05-output.conf index ada65fb..be2e6c9 100644 --- a/.config/sway/sway.d/05-output.conf +++ b/.config/sway/sway.d/05-output.conf @@ -7,19 +7,19 @@ -output "eDP-1" { - mode 1920x1080@60Hz - pos 1920 0 - transform normal -} -output "DP-3" { - mode 1920x1080@60Hz - pos 3840 0 - transform normal -} -output "DP-4" { - mode 1920x1080@60Hz - pos 0 0 - transform normal -} +# output "eDP-1" { +# mode 1920x1080@60Hz +# pos 1920 0 +# transform normal +# } +# output "DP-3" { +# mode 1920x1080@60Hz +# pos 3840 0 +# transform normal +# } +# output "DP-4" { +# mode 1920x1080@60Hz +# pos 0 0 +# transform normal +# } diff --git a/.config/sway/sway.d/07-hotkeys.conf b/.config/sway/sway.d/07-hotkeys.conf index 0b5a0d8..75688ec 100644 --- a/.config/sway/sway.d/07-hotkeys.conf +++ b/.config/sway/sway.d/07-hotkeys.conf @@ -138,6 +138,8 @@ mode "resize" { } bindsym $mod+r mode "resize" +## Lock screen +bindsym $mod+z exec ~/.config/sway/bin/lock.sh ## Screenshot // Screenshot active display // ## #bindsym Print exec $BIN_DIR/screenshots.sh display @@ -172,12 +174,23 @@ bindsym --locked XF86AudioMute exec volumectl toggle ## Modify // Mic mute // ## bindsym --locked XF86AudioMicMute exec amixer -D pulse sset Capture toggle && notify-send -t 1000 "Microphone state toggled" + +bindsym XF86AudioPlay exec volumectl down + +# bindsym XF86AudioRaiseVolume exec volumectl raise +# bindsym XF86AudioLowerVolume exec volumectl lower +# bindsym XF86AudioMute exec volumectl mute +# bindsym XF86AudioMicMute exec volumectl mute --mic + +# bindsym XF86MonBrightnessUp exec lightctl raise +# bindsym XF86MonBrightnessDown exec lightctl lower + + ## Notifications // Dismiss notification // ## bindsym $alt+space exec makoctl dismiss ## Notifications // Dismiss all notifications // ## bindsym Shift+$alt+space exec makoctl dismiss --all - ## Launch // Screen sharing // <> x ## bindsym $mod+x exec $BIN_DIR/dmenuscreenshare.sh diff --git a/.config/sway/sway.d/10-autostart.conf b/.config/sway/sway.d/10-autostart.conf index f7faf81..3ec32eb 100644 --- a/.config/sway/sway.d/10-autostart.conf +++ b/.config/sway/sway.d/10-autostart.conf @@ -2,6 +2,8 @@ exec --no-startup-id swaymsg 'workspace 1; exec $TERMINAL; workspace 2; exec bra exec wl-paste -t text --watch clipman store exec nm-applet --indicator +exec blueman-applet + set $gnome-schema org.gnome.desktop.interface exec_always { diff --git a/.config/systemd/user/kanshi.service b/.config/systemd/user/kanshi.service new file mode 100644 index 0000000..79bdd1e --- /dev/null +++ b/.config/systemd/user/kanshi.service @@ -0,0 +1,14 @@ +[Unit] +Description=Dynamic output configuration +Documentation=man:kanshi(1) +PartOf=sway-session.target +Requires=sway-session.target +After=sway-session.target + +[Service] +Type=simple +ExecStart=/usr/bin/kanshi +Restart=always + +[Install] +WantedBy=sway-session.target \ No newline at end of file diff --git a/.config/systemd/user/sway-session.target.wants/kanshi.service b/.config/systemd/user/sway-session.target.wants/kanshi.service new file mode 120000 index 0000000..91079aa --- /dev/null +++ b/.config/systemd/user/sway-session.target.wants/kanshi.service @@ -0,0 +1 @@ +/home/paramah/.config/systemd/user/kanshi.service \ No newline at end of file diff --git a/.config/systemd/user/sway-session.target.wants/swayidle.service b/.config/systemd/user/sway-session.target.wants/swayidle.service deleted file mode 120000 index 8b7bf05..0000000 --- a/.config/systemd/user/sway-session.target.wants/swayidle.service +++ /dev/null @@ -1 +0,0 @@ -/home/paramah/.config/systemd/user/swayidle.service \ No newline at end of file diff --git a/.config/systemd/user/swayidle.service b/.config/systemd/user/swayidle.service index e153808..06e2a5e 100644 --- a/.config/systemd/user/swayidle.service +++ b/.config/systemd/user/swayidle.service @@ -2,14 +2,13 @@ Description=Idle manager for Wayland Documentation=man:swayidle(1) PartOf=sway-session.target +Requires=sway-session.target +After=sway-session.target [Service] Type=simple -ExecStart=/usr/bin/swayidle -w timeout 300 '%h/.config/sway/bin/lock.sh' timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep '%h/.config/sway/bin/lock.sh' -ExecStop=/bin/kill -2 $MAINPID -Restart=on-failure -RestartSec=1 -TimeoutStopSec=10 +ExecStart=/home/paramah/.config/sway/bin/swayidle-conf +Restart=always [Install] WantedBy=sway-session.target diff --git a/.config/systemd/user/wayland-session.target.wants/kanshi.service b/.config/systemd/user/wayland-session.target.wants/kanshi.service new file mode 120000 index 0000000..91079aa --- /dev/null +++ b/.config/systemd/user/wayland-session.target.wants/kanshi.service @@ -0,0 +1 @@ +/home/paramah/.config/systemd/user/kanshi.service \ No newline at end of file diff --git a/.config/waybar/config b/.config/waybar/config index 83d1de6..92ae90d 100644 --- a/.config/waybar/config +++ b/.config/waybar/config @@ -125,6 +125,9 @@ "modules-center": [ ], "modules-right": [ + "custom/left-arrow-dark", + "custom/rsyncnet", + "custom/left-arrow-light", "custom/left-arrow-dark", "tray" ], @@ -181,6 +184,14 @@ "exec": "$HOME/.config/waybar/bin/sensor.sh pm10" }, + "custom/rsyncnet": { + "format": "{}", + "return-type": "text", + "interval": 60, + "exec": "cat /tmp/rsync.net" + }, + + "battery": { "states": { "good": 95, diff --git a/.config/waybar/style.css b/.config/waybar/style.css index de63f1f..92eb866 100644 --- a/.config/waybar/style.css +++ b/.config/waybar/style.css @@ -1,19 +1,19 @@ @import "../../.cache/wal/colors-waybar.css"; * { - font-size: 10px; + font-size: 12px; font-family: Terminus; } window#waybar { - background: none; + background: @back; color: @dark; } #custom-right-arrow-dark, #custom-left-arrow-dark { color: @dark; - background: none; + background: @back; } #custom-right-arrow-light, #custom-left-arrow-light { @@ -44,6 +44,7 @@ window#waybar { padding: 0 10px 0 10px; } +#custom-rsyncnet, #custom-temperature, #custom-hum, #custom-pressure, diff --git a/.zshrc b/.zshrc index bcd05eb..9317ed0 100644 --- a/.zshrc +++ b/.zshrc @@ -210,7 +210,7 @@ mattermost-desktop () { # launch telegram and send it to scratchpad theme () { wal -qi $WALLPAPER - swaybg --bg-scale $WALLPAPER + setwallpaper $WALLPAPER cp ~/.cache/wal/mako ~/.config/mako/config systemctl --user restart mako systemctl --user restart waybar @@ -337,3 +337,17 @@ export PAGER=bat alias ls="exa" #cat ~/.ideas +# + +if [[ "${TERM}" != "" && "${TERM}" == "xterm-256color" ]] +then + precmd() + { + print -Pn "\e]0;%~\a" + } + + preexec() + { + echo -en "\e]0;$(id --user --name)@$(hostname): ${1}\a" + } +fi