qusal/salt/dom0/screenshot.sls
Ben Grande 5722a25779
fix: discover non-root username at runtime
Useful when Dom0 has the non-default username, less useful for DomUs.

Fixes: https://github.com/ben-grande/qusal/issues/43
2024-04-30 16:04:40 +02:00

48 lines
1.3 KiB
Plaintext

{#
SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
SPDX-License-Identifier: AGPL-3.0-or-later
#}
{% if grains['nodename'] == 'dom0' -%}
{%- import slsdotpath ~ "/gui-user.jinja" as gui_user -%}
include:
- utils.tools.common.update
"{{ slsdotpath }}-screenshot-installed":
pkg.installed:
- require:
- sls: utils.tools.common.update
- install_recommends: False
- skip_suggestions: True
- pkgs:
- zenity
- scrot
"{{ slsdotpath }}-screenshot-script":
file.managed:
- name: /usr/local/bin/qvm-screenshot
- source: salt://{{ slsdotpath }}/files/bin/qvm-screenshot
- mode: "0755"
- user: root
- group: root
- makedirs: True
- require:
- pkg: "{{ slsdotpath }}-screenshot-installed"
## TODO: KDE shortcuts
"{{ slsdotpath }}-screenshot-keyboard-shortcuts-xfce":
cmd.run:
- name: |
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/{{ gui_user.gui_user_id }}/bus"
export DBUS_SESSION_BUS_ADDRESS
xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/Print" -n -s "qvm-screenshot --fullscreen"
xfconf-query -c xfce4-keyboard-shortcuts -p "/commands/custom/<Alt>Print" -n -s "qvm-screenshot --region"
- runas: {{ gui_user.gui_user }}
- require:
- file: "{{ slsdotpath }}-screenshot-script"
{% endif -%}