commit 82c36314d157b16b527d5eaa1c4c7bd15256acc0 Author: griffix Date: Fri Aug 1 14:59:36 2025 +0200 init files from local folder init with all my previous files diff --git a/Ansible/playbook-pi3.yml b/Ansible/playbook-pi3.yml new file mode 100755 index 0000000..833eabb --- /dev/null +++ b/Ansible/playbook-pi3.yml @@ -0,0 +1,167 @@ +--- +# +#Configuration du pi5 from scratch +# +#pré-requis : +#ssh configuré +# +# +- name: Configuration du pi3 from scratch + hosts: pi3 + remote_user: griffix + roles: + - geerlingguy.docker + become: true + tasks: + +#ajout du groupe docker + - name: Création du groupe docker + ansible.builtin.group: + name: docker + state: present + become: true + + - name: Ensure group "somegroup" exists + ansible.builtin.group: + name: media + state: present + become: true + +#Ajout du user griffix aux groupes docker et media + - name: Ajout du user griffix au groupe docker + ansible.builtin.user: + name: griffix + groups: docker,media + become: true + + + +# #mount 8Tb HDD externe +# #UUID=8d9ea59e-4f9a-48d8-94bc-9604f7c131a4 /media/Seagate ext4 defaults,auto,users,rw,nofail,noatime 0 0 +# - name: Mount up device by UUID +# ansible.posix.mount: +# path: /media/Seagate +# src: UUID=8d9ea59e-4f9a-48d8-94bc-9604f7c131a4 +# fstype: ext4 +# opts: defaults,auto,users,rw,nofail,noatime +# state: present +# become: true + +# #mount 500 Gb SSD +# #UUID=6177babe-d97c-4837-a326-1e557a5a3119 /temp ext4 defaults,auto,users,rw,nofail,noatime 0 0 +# - name: Mount up device by UUID +# ansible.posix.mount: +# path: /temp +# src: UUID=6177babe-d97c-4837-a326-1e557a5a3119 +# fstype: ext4 +# opts: defaults,auto,users,rw,nofail,noatime +# state: present +# become: true + +#reboot pour prendre en compte les disques + + # - name: Reboot machine and send a message + # ansible.builtin.reboot: + # msg: "Reboot du pi5 dans 5 secondes pour prise en compte des ajouts de disques en Fstab" + # become: true + + + - name: apt update d'abord + ansible.builtin.apt: + update_cache: yes + become: true + + - name: Update des packages déjà installés + ansible.builtin.apt: + name: "*" + state: latest + become: true + + - name: Installation des packages qui vont bien + ansible.builtin.apt: + pkg: + - fish + - docker + - btop + - vim + - nfs-kernel-server + become: true + +#confort en cas de log en local + - name: update profile root + lineinfile: + dest: ~/.profile + state: present + line: "alias ll='ls -alrth'" + become: true + + - name: update profile griffix + lineinfile: + dest: ~/.profile + state: present + line: "alias ll='ls -alrth'" +# #Share Seagate +# - name: Share seagate +# lineinfile: +# dest: /etc/exports +# state: present +# line: "/media/Seagate 192.168.1.0/24(rw,all_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1001)" +# become: true + +# #share Temp +# - name: share temp +# lineinfile: +# dest: /etc/exports +# state: present +# line: "/temp 192.168.1.0/24(rw,all_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1001)" +# become: true + + # - name: Reboot machine and send a message + # ansible.builtin.reboot: + # msg: "Reboot du pi5 dans 5 secondes pour prise en compte des installations et" + # become: true + + + # - name: Copy file with owner and permissions + # ansible.builtin.copy: + # src: /media/Seagate/Ansible_conf/config/ + # dest: /config + # owner: griffix + # group: media + # mode: '0766' + + # - name: Create directory for Docker CLI plugins + # file: + # path: /usr/local/lib/docker/cli-plugins + # state: directory + # mode: '0755' + # become: true + + # - name: Download Docker Compose V2 binary + # get_url: + # url: https://github.com/docker/compose/releases/download/v2.34.0/docker-compose-linux-aarch64 + # dest: /usr/local/lib/docker/cli-plugins/docker-compose + # mode: '0755' + # become: true + + # - name: Make Docker Compose binary executable + # file: + # path: /usr/local/lib/docker/cli-plugins/docker-compose + # mode: '0755' + # become: true + + # - name: Verify Docker Compose installation + # command: docker compose version + # register: docker_compose_version + # ignore_errors: yes + + # - name: Show Docker Compose version + # debug: + # msg: "{{ docker_compose_version.stdout }}" + # when: docker_compose_version.rc == 0 + + + - name: Create and deploy docker compose services + community.docker.docker_compose_v2: + project_src: /config/ + register: output \ No newline at end of file diff --git a/Ansible/playbook-pi4-backup.yml b/Ansible/playbook-pi4-backup.yml new file mode 100755 index 0000000..1edcd5f --- /dev/null +++ b/Ansible/playbook-pi4-backup.yml @@ -0,0 +1,24 @@ +--- +# +#Backup du pi5 +# +- name: Configuration du pi5 from scratch + hosts: pi5 + remote_user: griffix + tasks: + + - name: stop docker compose services + community.docker.docker_compose_v2: + project_src: /config/ + state: stopped + register: output + + - synchronize: + src: /config/ + dest: /media/Seagate/backups/pi5 + delegate_to: "{{ inventory_hostname }}" + + - name: re-deploy docker compose services + community.docker.docker_compose_v2: + project_src: /config/ + register: output \ No newline at end of file diff --git a/Ansible/playbook-pi5-backup.yml b/Ansible/playbook-pi5-backup.yml new file mode 100755 index 0000000..1edcd5f --- /dev/null +++ b/Ansible/playbook-pi5-backup.yml @@ -0,0 +1,24 @@ +--- +# +#Backup du pi5 +# +- name: Configuration du pi5 from scratch + hosts: pi5 + remote_user: griffix + tasks: + + - name: stop docker compose services + community.docker.docker_compose_v2: + project_src: /config/ + state: stopped + register: output + + - synchronize: + src: /config/ + dest: /media/Seagate/backups/pi5 + delegate_to: "{{ inventory_hostname }}" + + - name: re-deploy docker compose services + community.docker.docker_compose_v2: + project_src: /config/ + register: output \ No newline at end of file diff --git a/Ansible/playbook-pi5-end.yml b/Ansible/playbook-pi5-end.yml new file mode 100755 index 0000000..c4d86ae --- /dev/null +++ b/Ansible/playbook-pi5-end.yml @@ -0,0 +1,48 @@ +--- +# +#Configuration du pi5 from scratch +# +#pré-requis : +#ssh configuré +# +# +- name: Configuration du pi5 from scratch + hosts: pi5 + remote_user: griffix + tasks: + + - name: créer le /config + ansible.builtin.file: + path: /config + state: directory + owner: griffix + group: docker + mode: 0775 + become: true + + # - name: Copy file with owner and permissions + # ansible.builtin.copy: + # src: /media/Seagate/Ansible_conf/config/ + # dest: /config/ + # owner: griffix + # group: media + # mode: '0766' + + - synchronize: + src: /media/Seagate/Ansible_conf/config/ + dest: /config/ + delegate_to: "{{ inventory_hostname }}" + become: true + + - name: Recursively change ownership of a directory + ansible.builtin.file: + path: /config + state: directory + recurse: yes + owner: griffix + group: docker + + - name: create and deploy docker compose services + community.docker.docker_compose_v2: + project_src: /config/ + register: output \ No newline at end of file diff --git a/Ansible/playbook-pi5.yml b/Ansible/playbook-pi5.yml new file mode 100755 index 0000000..1adec2d --- /dev/null +++ b/Ansible/playbook-pi5.yml @@ -0,0 +1,142 @@ +--- +# +#Configuration du pi5 from scratch +# +#pré-requis : +#ssh configuré +# +# +- name: Configuration du pi5 from scratch + hosts: pi5 + remote_user: griffix + roles: + - geerlingguy.docker + become: true + tasks: + +#ajout du groupe docker + - name: Création du groupe docker + ansible.builtin.group: + name: docker + state: present + become: true + + - name: Ensure group "somegroup" exists + ansible.builtin.group: + name: media + state: present + become: true + +#Ajout du user griffix aux groupes docker et media + - name: Ajout du user griffix au groupe docker + ansible.builtin.user: + name: griffix + groups: docker,media + become: true + + +#mount 8Tb HDD externe +#UUID=8d9ea59e-4f9a-48d8-94bc-9604f7c131a4 /media/Seagate ext4 defaults,auto,users,rw,nofail,noatime 0 0 + - name: Mount up device by UUID + ansible.posix.mount: + path: /media/Seagate + src: UUID=8d9ea59e-4f9a-48d8-94bc-9604f7c131a4 + fstype: ext4 + opts: defaults,auto,users,rw,nofail,noatime + state: present + become: true + +#mount 500 Gb SSD +#UUID=6177babe-d97c-4837-a326-1e557a5a3119 /temp ext4 defaults,auto,users,rw,nofail,noatime 0 0 + - name: Mount up device by UUID + ansible.posix.mount: + path: /temp + src: UUID=6177babe-d97c-4837-a326-1e557a5a3119 + fstype: ext4 + opts: defaults,auto,users,rw,nofail,noatime + state: present + become: true + +#reboot pour prendre en compte les disques + + - name: Reboot machine and send a message + ansible.builtin.reboot: + msg: "Reboot du pi5 dans 5 secondes pour prise en compte des ajouts de disques en Fstab" + become: true + + - name: apt update d'abord + ansible.builtin.apt: + update_cache: yes + become: true + + - name: Update all packages to their latest version + ansible.builtin.apt: + name: "*" + state: latest + become: true + + - name: Installation des packages qui vont bien + ansible.builtin.apt: + pkg: + - fish + - btop + - vim + - nfs-kernel-server + become: true + +#confort en cas de log en local + - name: update profile root avec l'alias qui va bien + lineinfile: + dest: ~/.profile + state: present + line: "alias ll='ls -alrth'" + become: true + + - name: update profile griffix avec l'alias qui va bien + lineinfile: + dest: ~/.profile + state: present + line: "alias ll='ls -alrth'" + - name: update profile griffix avec l'alias qui va bien + lineinfile: + dest: ~/.profile + state: present + line: "alias dc='docker compose'" + + - name: Configuration du partage de Seagate + lineinfile: + dest: /etc/exports + state: present + line: "/media/Seagate 192.168.1.0/24(rw,all_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1001)" + become: true + + - name: Configuration du partage de temp + lineinfile: + dest: /etc/exports + state: present + line: "/temp 192.168.1.0/24(rw,all_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1001)" + become: true + + - name: Reboot machine and send a message + ansible.builtin.reboot: + msg: "Reboot du pi5 dans 5 secondes pour prise en compte des installations et" + become: true + + - synchronize: + src: /media/Seagate/Ansible_conf/config/ + dest: /config/ + delegate_to: "{{ inventory_hostname }}" + become: true + + - name: Recursively change ownership of a directory + ansible.builtin.file: + path: /config + state: directory + recurse: yes + owner: griffix + group: docker + + - name: create and deploy docker compose services + community.docker.docker_compose_v2: + project_src: /config/ + register: output \ No newline at end of file diff --git a/docker/pi4/docker-compose.yaml b/docker/pi4/docker-compose.yaml new file mode 100755 index 0000000..cdc5279 --- /dev/null +++ b/docker/pi4/docker-compose.yaml @@ -0,0 +1,41 @@ +--- +services: + + watchtower: + image: containrrr/watchtower + volumes: + - /var/run/docker.sock:/var/run/docker.sock + + Gitea: + image: docker.gitea.com/gitea:latest + container_name: gitea + environment: + - USER_UID=1000 + - USER_GID=1000 + restart: always + networks: + - gitea + volumes: + - /data/gitea:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + - "8080:3000" + - "2221:22" + + nginx: + image: nginx:latest + container_name: nginx-proxy + ports: + - "80:80" + - "443:443" + volumes: + - /config/nginx/nginx.conf:/etc/nginx/nginx.conf + - /config/nginx/certs:/etc/nginx/certs + +networks: + gitea: + external: false + default: + external: true + name: nginx-proxy-net \ No newline at end of file diff --git a/docker/pi5/.env b/docker/pi5/.env new file mode 100644 index 0000000..e69de29 diff --git a/docker/pi5/docker-compose.yaml b/docker/pi5/docker-compose.yaml new file mode 100755 index 0000000..83d45d9 --- /dev/null +++ b/docker/pi5/docker-compose.yaml @@ -0,0 +1,247 @@ +--- +services: + + portainer: + image: portainer/portainer-ce:latest + container_name: portainer + restart: unless-stopped + security_opt: + - no-new-privileges:true + volumes: + - /etc/localtime:/etc/localtime:ro + - /var/run/docker.sock:/var/run/docker.sock:ro + - /config/portainer-data:/data + ports: + - 9000:9000 + + flaresolverr: + image: ghcr.io/flaresolverr/flaresolverr:latest + container_name: flaresolverr + environment: + - LOG_LEVEL=${LOG_LEVEL:-info} + - LOG_HTML=${LOG_HTML:-false} + - CAPTCHA_SOLVER=${CAPTCHA_SOLVER:-none} + - TZ=Europe/London + ports: + - "${PORT:-8191}:8191" + restart: unless-stopped + + prowlarr: + image: lscr.io/linuxserver/prowlarr:latest + container_name: prowlarr + environment: + - PUID=1000 + - PGID=1000 + - TZ=Europe/Paris + volumes: + - /config/prowlarr:/config + ports: + - 9696:9696 + restart: unless-stopped + + sonarr: + image: lscr.io/linuxserver/sonarr:latest + container_name: sonarr + environment: + - PUID=1000 + - PGID=1000 + - TZ=Europe/Paris + volumes: + - /config/sonarr:/config + - /media/Seagate/Series:/media/Seagate/Series + - /media/Seagate/Animes:/media/Seagate/Animes + - /temp:/temp + ports: + - 8989:8989 + restart: unless-stopped + + radarr: + image: lscr.io/linuxserver/radarr:latest + container_name: radarr + environment: + - PUID=1000 + - PGID=1000 + - TZ=Europe/Paris + volumes: + - /config/radarr:/config + - /media/Seagate/Movies:/media/Seagate/Movies + - /media/Seagate/temp:/media/Seagate/temp + - /temp:/temp + ports: + - 7878:7878 + restart: unless-stopped + + gluetun: + image: qmcgaw/gluetun + container_name: gluetun + cap_add: + - NET_ADMIN + devices: + - /dev/net/tun:/dev/net/tun + environment: + - VPN_SERVICE_PROVIDER=nordvpn + - VPN_TYPE=wireguard + - WIREGUARD_PRIVATE_KEY=IPknikpWm9Q11ekbUNU1UQPNVb08XMoEGdfOUqcQnn4= + - SERVER_COUNTRIES=France + - SERVER_CATEGORIES=P2P + - HTTPPROXY=on + - HTTPPROXY_LOG=on + ports: + - 8888:8888 + - 6881:6881 + - 8080:8080 + + qbit: + image: ghcr.io/linuxserver/qbittorrent + container_name: qbit + volumes: + - /temp:/temp + - /config/transmission-daemon:/config + environment: + - PUID=1000 + - PGID=1000 + network_mode: "service:gluetun" + restart: always + + jellyfin: + image: lscr.io/linuxserver/jellyfin:latest + container_name: jellyfin + environment: + - PUID=1000 + - PGID=1000 + - TZ=Europe/Paris + - JELLYFIN_PublishedServerUrl=192.168.1.55 #optional + volumes: + - /config/jellyfin:/config + - /media/Seagate/Series:/Series + - /media/Seagate/Animes:/Animes + - /media/Seagate/Movies:/Movies + ports: + - 8096:8096 + - 8920:8920 #optional + - 7359:7359/udp #optional + - 1900:1900/udp #optional + restart: unless-stopped + + watchtower: + image: containrrr/watchtower + volumes: + - /var/run/docker.sock:/var/run/docker.sock + + immich-server: + container_name: immich_server + image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} + # extends: + # file: hwaccel.transcoding.yml + # service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding + volumes: + # Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file + - ${UPLOAD_LOCATION}:/usr/src/app/upload + - /etc/localtime:/etc/localtime:ro + env_file: + - path: .env + required: true + ports: + - '2283:2283' + depends_on: + - redis + - database + restart: always + healthcheck: + disable: false + + immich-machine-learning: + container_name: immich_machine_learning + # For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag. + # Example tag: ${IMMICH_VERSION:-release}-cuda + image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release} + # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration + # file: hwaccel.ml.yml + # service: cpu # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn] for accelerated inference - use the `-wsl` version for WSL2 where applicable + volumes: + - model-cache:/cache + env_file: + - path: .env + required: true + restart: always + healthcheck: + disable: false + + redis: + container_name: immich_redis + image: docker.io/valkey/valkey:8-bookworm@sha256:fec42f399876eb6faf9e008570597741c87ff7662a54185593e74b09ce83d177 + healthcheck: + test: redis-cli ping || exit 1 + restart: always + + database: + container_name: immich_postgres + image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0 + env_file: + - path: .env + required: true + environment: + POSTGRES_PASSWORD: ${DB_PASSWORD} + POSTGRES_USER: ${DB_USERNAME} + POSTGRES_DB: ${DB_DATABASE_NAME} + POSTGRES_INITDB_ARGS: '--data-checksums' + # Uncomment the DB_STORAGE_TYPE: 'HDD' var if your database isn't stored on SSDs + # DB_STORAGE_TYPE: 'HDD' + volumes: + # Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file + - ${DB_DATA_LOCATION}:/var/lib/postgresql/data + restart: always + + #volumes: + #model-cache: + + Gitea: + image: docker.gitea.com/gitea:latest + container_name: gitea + environment: + - USER_UID=1000 + - USER_GID=1000 + restart: always + networks: + - gitea + volumes: + - /config/gitea:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + - "8080:3000" + - "2221:22" + Forgejo: + image: codeberg.org/forgejo/forgejo:11 + container_name: forgejo + environment: + - USER_UID=1000 + - USER_GID=1000 + restart: always + networks: + - forgejo + volumes: + - /config/forgejo:/data + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + - '3000:3000' + - '222:22' + nginx: + image: nginx:latest + container_name: nginx-proxy + ports: + - "80:80" + - "443:443" + volumes: + - /config/nginx/nginx.conf:/etc/nginx/nginx.conf + - /config/nginx/certs:/etc/nginx/certs + +networks: + gitea: + external: false + default: + external: true +# name: nginx-proxy-net +volumes: + model-cache: diff --git a/hs80/Corsair-HS80-GNOME-extension b/hs80/Corsair-HS80-GNOME-extension new file mode 160000 index 0000000..013b790 --- /dev/null +++ b/hs80/Corsair-HS80-GNOME-extension @@ -0,0 +1 @@ +Subproject commit 013b790a0ca9ca4d54bf38e7c64ff4f9f6a2ab33 diff --git a/hs80/Corsairev2 b/hs80/Corsairev2 new file mode 100755 index 0000000..6c410d9 Binary files /dev/null and b/hs80/Corsairev2 differ diff --git a/hs80/corsair_working1.0 b/hs80/corsair_working1.0 new file mode 100755 index 0000000..7c3ad3f Binary files /dev/null and b/hs80/corsair_working1.0 differ diff --git a/hs80/corsairev2.rs b/hs80/corsairev2.rs new file mode 100644 index 0000000..dea3d53 --- /dev/null +++ b/hs80/corsairev2.rs @@ -0,0 +1,55 @@ +use hidapi::{HidApi}; + +const CORSAIR_VID: u16 = 0x1B1C; +const HS80_PID: u16 = 0x0A6B; + +fn main() -> Result<(), Box> { + println!("VID/PID : "); + println!("{}",CORSAIR_VID); + println!("{}",HS80_PID); + + let api = HidApi::new()?; + + let device = api.open(CORSAIR_VID, HS80_PID)?; + let mut buffer = [0u8; 64]; + + println!("Reading from device"); + + loop { + match device.read(&mut buffer) { + Ok(size) => { + /*for i in 0..size { + print!("{:02X} ", buffer[i]); + }*/ + if size > 2 { + match buffer[3] { + 0x0f => { + println!("Received battery change event"); + let percentage = (buffer[5] as u16 | (buffer[6] as u16) << 8) as f64 / 10.0; + println!("Battery Percentage: {:.1}%", percentage); + } + 0x10 => { + println!("Received charging state change event"); + let charging = buffer[5] == 1; + println!("Charging: {}", charging); + } + 0xA6 => { + println!("Received mic state change event"); + let micro = buffer[5] == 0; + println!("Micro actif: {}", micro); + } + _ => { + println!("Unsupported event"); + } + } + } + } + Err(e) => { + println!("Error reading from device: {}", e); + break; + } + } + }; + + Ok(()) +} diff --git a/hs80/hs80-kde-extension/package/contents/config/config.qml b/hs80/hs80-kde-extension/package/contents/config/config.qml new file mode 100644 index 0000000..e69de29 diff --git a/hs80/hs80-kde-extension/package/contents/config/main.xml b/hs80/hs80-kde-extension/package/contents/config/main.xml new file mode 100644 index 0000000..e69de29 diff --git a/hs80/hs80-kde-extension/package/contents/ui/configGeneral.qml b/hs80/hs80-kde-extension/package/contents/ui/configGeneral.qml new file mode 100644 index 0000000..e69de29 diff --git a/hs80/hs80-kde-extension/package/contents/ui/main.qml b/hs80/hs80-kde-extension/package/contents/ui/main.qml new file mode 100644 index 0000000..d9489fa --- /dev/null +++ b/hs80/hs80-kde-extension/package/contents/ui/main.qml @@ -0,0 +1,9 @@ +import QtQuick +import org.kde.plasma.plasmoid +import org.kde.plasma.components as PlasmaComponents + +PlasmoidItem{ + PlasmaComponents.Label { + text: "Hello World!" + } +} \ No newline at end of file diff --git a/hs80/hs80-kde-extension/package/metadata.json b/hs80/hs80-kde-extension/package/metadata.json new file mode 100644 index 0000000..98efdcc --- /dev/null +++ b/hs80/hs80-kde-extension/package/metadata.json @@ -0,0 +1,20 @@ +{ + "KPlugin": { + "Authors": [ + { + "Email": "vbriday@gmail.com", + "Name": "Victor Briday" + } + ], + "Category": "System Information", + "Description": "hs80 status tray", + "Icon": "headset", + "Id": "com.example.hs80tray", + "Name": "hs80tray", + "Version": "1", + "Website": "https://example.com/user/plasmoid-helloworldplugin", + "BugReportUrl": "https://example.com/user/plasmoid-helloworldplugin/bugs" + }, + "X-Plasma-API-Minimum-Version": "6.0", + "KPackageStructure": "Plasma/Applet" +} \ No newline at end of file diff --git a/hs80/hw b/hs80/hw new file mode 100755 index 0000000..aa3036b Binary files /dev/null and b/hs80/hw differ diff --git a/hs80/hw.rs b/hs80/hw.rs new file mode 100644 index 0000000..03411c5 --- /dev/null +++ b/hs80/hw.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello world!!"); +} diff --git a/hs80/main.rs b/hs80/main.rs new file mode 100644 index 0000000..6b97046 --- /dev/null +++ b/hs80/main.rs @@ -0,0 +1,81 @@ +use hidapi::{HidApi}; +use dbus::blocking::{Connection}; +use dbus::channel::Sender; +use dbus::{Message, Path}; +use dbus::strings::{Interface, Member}; + +const CORSAIR_VID: u16 = 0x1B1C; +const HS80_PID: u16 = 0x0A6B; + +struct DBusSignalSender { + connection: Connection, + path: Path<'static>, + interface: Interface<'static> +} + +impl DBusSignalSender { + + fn new(path: &str, interface: &str) -> Self { + + let connection = Connection::new_session().expect("Failed to connect to DBus"); + + Self { + connection, + path: Path::new(path).expect("Invalid Path"), + interface: Interface::new(interface).expect("Invalid Interface") + } + } + + fn send_update(&self, update: i32) { + let msg = Message::signal( + &self.path, + &self.interface, + &Member::new("HS80").expect("Invalid Signal name"), + ).append1(update); + + self.connection.send(msg).expect("Failed to send Signal"); + } + +} + +fn main() -> Result<(), Box> { + + // Initialize the sender with borrowed string literals + let sender = DBusSignalSender::new( + "/com/h0psej0ch/corsair", // Object path + "com.h0psej0ch.corsair.Interface", // Interface + ); + + // Initialize the HID interface with the VID and PID of the HS-80 Headset + let api = HidApi::new()?; + let device = api.open(CORSAIR_VID, HS80_PID)?; + let mut buffer = [0u8; 64]; + + // Indefinitely loop and read the device + loop { + match device.read(&mut buffer) { + Ok(size) => { + + if size > 2 { + match buffer[3] { + 0x0f => { + let percentage = (buffer[5] as u16 | (buffer[6] as u16) << 8) as f64 / 10.0; + sender.send_update(percentage as i32); + } + 0x10 => { + let charging = buffer[5] == 1; + sender.send_update(if charging {-1} else {-2}); + } + _ => {} + } + } + } + Err(e) => { + println!("Error reading from device: {}", e); + break; + } + } + }; + + Ok(()) +} diff --git a/hs80/main_working1.0.rs b/hs80/main_working1.0.rs new file mode 100644 index 0000000..c9614ae --- /dev/null +++ b/hs80/main_working1.0.rs @@ -0,0 +1,52 @@ +use hidapi::{HidApi}; + +const CORSAIR_VID: u16 = 0x1B1C; +const HS80_PID: u16 = 0x0A6B; + +//fn main() -> Result<(), Box> { + +fn main() -> Result<(), Box> { + println!("VID/PID : "); + println!("{}",CORSAIR_VID); + println!("{}",HS80_PID); + + let api = HidApi::new()?; + + let device = api.open(CORSAIR_VID, HS80_PID)?; + let mut buffer = [0u8; 64]; + + println!("Reading from device"); + + loop { + match device.read(&mut buffer) { + Ok(size) => { + for i in 0..size { + print!("{:02X} ", buffer[i]); + } + if size > 2 { + match buffer[3] { + 0x0f => { + println!("Received battery change event"); + let percentage = (buffer[5] as u16 | (buffer[6] as u16) << 8) as f64 / 10.0; + println!("Battery Percentage: {:.1}%", percentage); + } + 0x10 => { + println!("Received charging state change event"); + let charging = buffer[5] == 1; + println!("Charging: {}", charging); + } + _ => { + println!("Unsupported event"); + } + } + } + } + Err(e) => { + println!("Error reading from device: {}", e); + break; + } + } + }; + + Ok(()) +} \ No newline at end of file diff --git a/infra_conf/test/nginx/docker_nginx.yml b/infra_conf/test/nginx/docker_nginx.yml new file mode 100755 index 0000000..8d644b6 --- /dev/null +++ b/infra_conf/test/nginx/docker_nginx.yml @@ -0,0 +1,15 @@ +services: + nginx: + image: nginx:latest + container_name: nginx-proxy + ports: + - "80:80" + - "443:443" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + - ./certs:/etc/nginx/certs + +networks: + default: + external: + name: nginx-proxy-net \ No newline at end of file diff --git a/infra_conf/test/nginx/nginx.conf b/infra_conf/test/nginx/nginx.conf new file mode 100755 index 0000000..e55244a --- /dev/null +++ b/infra_conf/test/nginx/nginx.conf @@ -0,0 +1,94 @@ +events { + worker_connections 4096; ## Default: 1024 +} +http { +# radarr + server { + listen 80; + server_name griffix.hopto.org:7878; + location / { + proxy_pass http://192.168.1.55:7878; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + } +# server { +# listen 443 ssl; +# server_name www.first.com first.com; +# ssl_certificate /etc/nginx/certs/ssl_cert.crt; +# ssl_certificate_key /etc/nginx/certs/ssl_key.key; +# location / { +# proxy_pass http://first_container:first_port; +# proxy_set_header Host $host; +# proxy_set_header X-Real-IP $remote_addr; +# } +# } +# } + +# sonarr + server { + listen 80; + server_name griffix.hopto.org:8989; + location / { + proxy_pass http://192.168.1.55:8989; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + } +# server { +# listen 443 ssl; +# server_name www.second.com second.com; +# ssl_certificate /etc/nginx/certs/ssl_cert.crt; +# ssl_certificate_key /etc/nginx/certs/ssl_key.key; +# location / { +# proxy_pass http://second_container:second_port; +# proxy_set_header Host $host; +# proxy_set_header X-Real-IP $remote_addr; +# } +# } +# } + +# qbit + server { + listen 80; + server_name griffix.hopto.org:8081; + location / { + proxy_pass http://192.168.1.55:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + } +# server { +# listen 443 ssl; +# server_name www.second.com second.com; +# ssl_certificate /etc/nginx/certs/ssl_cert.crt; +# ssl_certificate_key /etc/nginx/certs/ssl_key.key; +# location / { +# proxy_pass http://second_container:second_port; +# proxy_set_header Host $host; +# proxy_set_header X-Real-IP $remote_addr; +# } +# } + +# Jellyfin + server { + listen 80; + server_name griffix.hopto.org:8096; + location / { + proxy_pass http://192.168.1.55:8096; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + } +# server { +# listen 443 ssl; +# server_name www.second.com second.com; +# ssl_certificate /etc/nginx/certs/ssl_cert.crt; +# ssl_certificate_key /etc/nginx/certs/ssl_key.key; +# location / { +# proxy_pass http://second_container:second_port; +# proxy_set_header Host $host; +# proxy_set_header X-Real-IP $remote_addr; +# } +# } +} \ No newline at end of file