Skip to content

Commit f9b0f4d

Browse files
authored
Merge pull request #651 from chmodmasx/master
send-to-telegram@chmodmasx: Add action
2 parents b510f42 + 9339075 commit f9b0f4d

File tree

10 files changed

+234
-0
lines changed

10 files changed

+234
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### 1.0
2+
3+
- Initial release

send-to-telegram@chmodmasx/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# (EN) SEND TO TELEGRAM
2+
3+
Send file(s) to Telegram
4+
5+
## DESCRIPTION
6+
7+
Send file(s) to Telegram, remember that Telegram does not accept folders to be sent.
8+
9+
# (ES) ENVIAR A TELEGRAM
10+
11+
Enviar archivo(s) por Telegram
12+
13+
## DESCRIPCIÓN
14+
15+
Envía archivo(s) por Telegram. Recuerda que Telegram no acepta carpetas para ser enviadas.
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"description": "Send files to telegram",
3+
"uuid": "send-to-telegram@chmodmasx",
4+
"name": "Send to telegram",
5+
"author": "chmodmasx",
6+
"version": "1.0"
7+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SEND TO TELEGRAM
2+
# This file is put in the public domain.
3+
# chmodmasx, 2023
4+
#
5+
#, fuzzy
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: send-to-telegram@chmodmasx 1.0\n"
9+
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-actions/"
10+
"issues\n"
11+
"POT-Creation-Date: 2025-04-06 20:03-0300\n"
12+
"PO-Revision-Date: \n"
13+
"Last-Translator: \n"
14+
"Language-Team: \n"
15+
"Language: es\n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"X-Generator: Poedit 3.4.4\n"
20+
21+
#. metadata.json->description
22+
msgid "Send files to telegram"
23+
msgstr "Enviar archivos a telegram"
24+
25+
#. metadata.json->name
26+
msgid "Send to telegram"
27+
msgstr "Enviar a telegram"
28+
29+
#. send-to-telegram@chmodmasx.nemo_action.in->Name
30+
msgid "Send to Telegram"
31+
msgstr "Enviar a Telegram"
32+
33+
#. send-to-telegram@chmodmasx.nemo_action.in->Comment
34+
msgid "Send files to Telegram from the context menu"
35+
msgstr "Enviar archivos a Telegram desde el menú contextual"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SEND TO TELEGRAM
2+
# This file is put in the public domain.
3+
# chmodmasx, 2023
4+
#
5+
#, fuzzy
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: send-to-telegram@chmodmasx 1.0\n"
9+
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-actions/"
10+
"issues\n"
11+
"POT-Creation-Date: 2025-04-06 20:03-0300\n"
12+
"PO-Revision-Date: \n"
13+
"Last-Translator: \n"
14+
"Language-Team: \n"
15+
"Language: es_AR\n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"X-Generator: Poedit 3.4.4\n"
20+
21+
#. metadata.json->description
22+
msgid "Send files to telegram"
23+
msgstr "Enviar archivos a telegram"
24+
25+
#. metadata.json->name
26+
msgid "Send to telegram"
27+
msgstr "Enviar a telegram"
28+
29+
#. send-to-telegram@chmodmasx.nemo_action.in->Name
30+
msgid "Send to Telegram"
31+
msgstr "Enviar a Telegram"
32+
33+
#. send-to-telegram@chmodmasx.nemo_action.in->Comment
34+
msgid "Send files to Telegram from the context menu"
35+
msgstr "Enviar archivos a telegram desde el menú contextual"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# SEND TO TELEGRAM
2+
# This file is put in the public domain.
3+
# chmodmasx, 2023
4+
#
5+
#, fuzzy
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: send-to-telegram@chmodmasx 1.0\n"
9+
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-actions/"
10+
"issues\n"
11+
"POT-Creation-Date: 2025-04-06 20:03-0300\n"
12+
"PO-Revision-Date: \n"
13+
"Last-Translator: \n"
14+
"Language-Team: \n"
15+
"Language: \n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
20+
#. metadata.json->description
21+
msgid "Send files to telegram"
22+
msgstr ""
23+
24+
#. metadata.json->name
25+
msgid "Send to telegram"
26+
msgstr ""
27+
28+
#. send-to-telegram@chmodmasx.nemo_action.in->Name
29+
msgid "Send to Telegram"
30+
msgstr ""
31+
32+
#. send-to-telegram@chmodmasx.nemo_action.in->Comment
33+
msgid "Send files to Telegram from the context menu"
34+
msgstr ""
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env bash
2+
3+
arr=()
4+
SAVEIFS=$IFS
5+
IFS=$(echo -en "\n\b")
6+
7+
for var in "$@"
8+
do
9+
if [ -n "$var" ]; then
10+
path=$(readlink -f "$var")
11+
arr+=("$path")
12+
fi
13+
done
14+
15+
# Archivo de configuración para guardar ruta personalizada
16+
config_file="$HOME/.config/telegram_launcher.conf"
17+
18+
# Lista de posibles comandos para Telegram
19+
telegram_candidates=(
20+
"telegram-desktop"
21+
"telegram"
22+
"Telegram"
23+
"$HOME/.local/bin/Telegram"
24+
"/opt/telegram/Telegram"
25+
"/usr/bin/telegram-desktop"
26+
"/usr/local/bin/Telegram"
27+
)
28+
29+
telegram_cmd=""
30+
is_flatpak=false
31+
32+
# Cargar ruta personalizada si existe
33+
if [ -f "$config_file" ]; then
34+
saved_cmd=$(<"$config_file")
35+
if [ -x "$saved_cmd" ]; then
36+
telegram_cmd="$saved_cmd"
37+
fi
38+
fi
39+
40+
# Buscar el ejecutable de Telegram si no se cargó desde config
41+
if [ -z "$telegram_cmd" ]; then
42+
for cmd in "${telegram_candidates[@]}"; do
43+
if command -v "$cmd" >/dev/null 2>&1; then
44+
telegram_cmd="$cmd"
45+
break
46+
elif [[ -x "$cmd" ]]; then
47+
telegram_cmd="$cmd"
48+
break
49+
fi
50+
done
51+
fi
52+
53+
# Si no encontró ninguno, probar con Flatpak (sólo si está instalado Telegram)
54+
if [ -z "$telegram_cmd" ] && command -v flatpak >/dev/null; then
55+
if flatpak list --app | grep -q org.telegram.desktop; then
56+
telegram_cmd=(flatpak run --file-forwarding org.telegram.desktop)
57+
is_flatpak=true
58+
fi
59+
fi
60+
61+
# Ejecutar el comando con los archivos
62+
if [ -n "$telegram_cmd" ]; then
63+
if [ "$is_flatpak" = true ]; then
64+
"${telegram_cmd[@]}" -sendpath @@ "${arr[@]}" @@
65+
wmctrl -x -a Telegram
66+
else
67+
"$telegram_cmd" -sendpath "${arr[@]}"
68+
wmctrl -x -a Telegram.TelegramDesktop
69+
fi
70+
else
71+
zenity --question \
72+
--title="Telegram no encontrado" \
73+
--text="No se encontró una instalación de Telegram compatible.\n¿Querés seleccionar el ejecutable manualmente?"
74+
75+
if [ $? -eq 0 ]; then
76+
manual_path=$(zenity --file-selection --title="Seleccioná el ejecutable de Telegram")
77+
78+
if [ -n "$manual_path" ] && [ -x "$manual_path" ]; then
79+
telegram_cmd="$manual_path"
80+
echo "$telegram_cmd" > "$config_file"
81+
"$telegram_cmd" -sendpath "${arr[@]}"
82+
wmctrl -x -a Telegram.TelegramDesktop
83+
else
84+
zenity --error --title="Error" --text="El archivo seleccionado no es un ejecutable válido."
85+
exit 1
86+
fi
87+
else
88+
zenity --error --title="Telegram no encontrado" --text="No se pudo ejecutar Telegram."
89+
exit 1
90+
fi
91+
fi
92+
93+
IFS=$SAVEIFS
94+

send-to-telegram@chmodmasx/info.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"author": "chmodmasx"
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Nemo Action]
2+
_Name=Send to Telegram
3+
_Comment=Send files to Telegram from the context menu
4+
Exec=<send-to-telegram@chmodmasx/send-to-telegram.sh %F>
5+
Icon-Name=telegram-desktop
6+
Selection=notnone
7+
Quote=double
8+
Extensions=nodirs

0 commit comments

Comments
 (0)